-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
228 lines (202 loc) · 6.94 KB
/
Copy pathscripts.js
File metadata and controls
228 lines (202 loc) · 6.94 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
document.addEventListener('DOMContentLoaded', () => {
const loadingSpinner = document.getElementById('loading-spinner');
if (loadingSpinner) {
window.addEventListener('load', () => {
loadingSpinner.style.display = 'none';
});
}
const navToggle = document.getElementById('js-navbar-toggle');
const menu = document.getElementById('js-menu');
if (navToggle) {
navToggle.addEventListener('click', () => {
menu.classList.toggle('active');
});
}
const navLinks = document.querySelectorAll('.navbar a');
const sections = document.querySelectorAll('section');
// Smooth scrolling for navigation links
navLinks.forEach(link => {
link.addEventListener('click', function (e) {
if (this.getAttribute('href').startsWith('#')) {
e.preventDefault();
const targetId = this.getAttribute('href').substring(1);
const targetSection = document.getElementById(targetId);
window.scrollTo({
top: targetSection.offsetTop - document.querySelector('.navbar').offsetHeight,
behavior: 'smooth'
});
// Close the menu on mobile after clicking a link
if (menu.classList.contains('active')) {
menu.classList.remove('active');
}
}
});
});
// Intersection Observer for fading in sections
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = 1;
}
});
}, { threshold: 0.1 });
sections.forEach(section => {
section.style.opacity = 0;
observer.observe(section);
});
// YouTube Data API Key
const API_KEY = CONFIG.YOUTUBE_API_KEY;
const CHANNEL_ID = CONFIG.YOUTUBE_CHANNEL_ID;
const MAX_RESULTS = 10;
// Fetch YouTube videos
function fetchYouTubeVideos() {
$.get(`https://www.googleapis.com/youtube/v3/search?key=${API_KEY}&channelId=${CHANNEL_ID}&part=snippet,id&order=date&maxResults=${MAX_RESULTS}`, function (data) {
let videoItems = '';
data.items.forEach(item => {
if (item.id.kind === "youtube#video") {
videoItems += `
<div class="carousel-item">
<iframe src="https://www.youtube.com/embed/${item.id.videoId}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
`;
}
});
$('.media-carousel').html(videoItems);
initializeCarousel();
});
}
// Initialize Slick carousel
function initializeCarousel() {
$('.media-carousel').slick({
infinite: true,
slidesToShow: 5,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 2000,
arrows: true,
dots: true,
responsive: [
{
breakpoint: 1024,
settings: {
slidesToShow: 3
}
},
{
breakpoint: 768,
settings: {
slidesToShow: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1
}
}
]
});
}
// Initialize Spotlight carousel
function initializeSpotlightCarousel() {
$('.spotlight-carousel').slick({
infinite: true,
slidesToShow: 2,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 3000,
arrows: true,
dots: true,
responsive: [
{
breakpoint: 768,
settings: {
slidesToShow: 1,
centerMode: true,
centerPadding: '20px'
}
}
]
});
}
// Disqus configuration
const disqus_config = function () {
this.page.url = CONFIG.DISQUS_PAGE_URL;
this.page.identifier = CONFIG.DISQUS_PAGE_IDENTIFIER;
};
(function () {
const d = document, s = d.createElement('script');
s.src = `https://${CONFIG.DISQUS_SHORTNAME}.disqus.com/embed.js`;
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
// Load Google Calendar
const googleCalendarSrc = `https://calendar.google.com/calendar/embed?src=${CONFIG.GOOGLE_CALENDAR_ID}&ctz=America%2FLos_Angeles`;
const calendarElement = document.getElementById('google-calendar');
if (calendarElement) {
calendarElement.src = googleCalendarSrc;
}
// Initialize AOS
AOS.init();
// Initialize the media carousel
fetchYouTubeVideos();
initializeCarousel();
// Initialize Spotlight carousel
initializeSpotlightCarousel();
// Initialize testimonials carousel
initializeTestimonialsCarousel();
// Lazy load images
const lazyImages = document.querySelectorAll('img.lazy');
const lazyObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const img = entry.target;
img.src = img.dataset.src;
img.classList.remove('lazy');
lazyObserver.unobserve(img);
}
});
});
lazyImages.forEach(img => {
lazyObserver.observe(img);
});
const backToTop = document.querySelector('.back-to-top');
window.addEventListener('scroll', () => {
if (window.scrollY > 300) {
backToTop.style.display = 'block';
} else {
backToTop.style.display = 'none';
}
});
backToTop.addEventListener('click', (e) => {
e.preventDefault();
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
function initializeTestimonialsCarousel() {
$('.testimonials-carousel').slick({
infinite: true,
slidesToShow: 2,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 3000,
arrows: false,
dots: true,
responsive: [
{
breakpoint: 768,
settings: {
slidesToShow: 1
}
}
]
});
}
// Initialize Snipcart API key
const snipcart = document.getElementById('snipcart');
if (snipcart) {
snipcart.setAttribute('data-api-key', CONFIG.SNIPCART_API_KEY);
}
});