Spaces:
Sleeping
Sleeping
File size: 18,262 Bytes
c0506a3 |
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 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
// Presentation JavaScript functionality
class Presentation {
constructor() {
this.currentSlide = 0;
this.totalSlides = 15;
this.slides = [];
this.isFullscreen = false;
this.init();
}
init() {
// Wait for DOM to be fully loaded
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => this.setupPresentation());
} else {
this.setupPresentation();
}
}
setupPresentation() {
this.slides = document.querySelectorAll('.slide');
console.log('Found slides:', this.slides.length);
if (this.slides.length === 0) {
console.error('No slides found!');
return;
}
this.totalSlides = this.slides.length;
this.bindEvents();
this.showSlide(0);
this.updateProgress();
this.updateCounter();
this.updateNavigationButtons();
}
bindEvents() {
// Button controls
const prevBtn = document.getElementById('prev-slide');
const nextBtn = document.getElementById('next-slide');
const fullscreenBtn = document.getElementById('fullscreen-toggle');
if (prevBtn) prevBtn.addEventListener('click', () => this.previousSlide());
if (nextBtn) nextBtn.addEventListener('click', () => this.nextSlide());
if (fullscreenBtn) fullscreenBtn.addEventListener('click', () => this.toggleFullscreen());
// Keyboard controls
document.addEventListener('keydown', (e) => this.handleKeydown(e));
// Fullscreen change events
document.addEventListener('fullscreenchange', () => this.handleFullscreenChange());
document.addEventListener('webkitfullscreenchange', () => this.handleFullscreenChange());
document.addEventListener('mozfullscreenchange', () => this.handleFullscreenChange());
document.addEventListener('msfullscreenchange', () => this.handleFullscreenChange());
// Touch/swipe events for mobile
this.addTouchEvents();
console.log('Event listeners bound successfully');
}
handleKeydown(e) {
switch(e.key) {
case 'ArrowRight':
case ' ':
case 'Enter':
e.preventDefault();
this.nextSlide();
break;
case 'ArrowLeft':
e.preventDefault();
this.previousSlide();
break;
case 'Home':
e.preventDefault();
this.goToSlide(0);
break;
case 'End':
e.preventDefault();
this.goToSlide(this.totalSlides - 1);
break;
case 'f':
case 'F':
if (!e.ctrlKey && !e.metaKey) {
e.preventDefault();
this.toggleFullscreen();
}
break;
case 'Escape':
if (this.isFullscreen) {
this.exitFullscreen();
}
break;
}
}
addTouchEvents() {
let startX = 0;
let startY = 0;
const container = document.querySelector('.presentation-container');
if (!container) return;
container.addEventListener('touchstart', (e) => {
startX = e.touches[0].clientX;
startY = e.touches[0].clientY;
}, { passive: true });
container.addEventListener('touchend', (e) => {
if (!startX || !startY) return;
const endX = e.changedTouches[0].clientX;
const endY = e.changedTouches[0].clientY;
const deltaX = startX - endX;
const deltaY = startY - endY;
// Only trigger if horizontal swipe is dominant and significant
if (Math.abs(deltaX) > Math.abs(deltaY) && Math.abs(deltaX) > 50) {
if (deltaX > 0) {
this.nextSlide();
} else {
this.previousSlide();
}
}
startX = 0;
startY = 0;
}, { passive: true });
}
nextSlide() {
if (this.currentSlide < this.totalSlides - 1) {
this.goToSlide(this.currentSlide + 1);
}
}
previousSlide() {
if (this.currentSlide > 0) {
this.goToSlide(this.currentSlide - 1);
}
}
goToSlide(slideIndex) {
if (slideIndex >= 0 && slideIndex < this.totalSlides) {
console.log(`Going to slide ${slideIndex + 1}`);
// Hide current slide
this.hideAllSlides();
// Update current slide index
this.currentSlide = slideIndex;
// Show new slide
this.showSlide(slideIndex);
// Update UI elements
this.updateProgress();
this.updateCounter();
this.updateNavigationButtons();
// Handle slide-specific logic
this.handleSlideSpecifics(slideIndex);
}
}
hideAllSlides() {
this.slides.forEach(slide => {
slide.classList.remove('active', 'animate-in');
});
}
showSlide(index) {
const slide = this.slides[index];
if (slide) {
// Remove active class from all slides first
this.hideAllSlides();
// Add active class to current slide
slide.classList.add('active');
// Add animation after a brief delay
setTimeout(() => {
slide.classList.add('animate-in');
this.animateSlideContent(slide);
}, 50);
}
}
animateSlideContent(slide) {
const elements = slide.querySelectorAll('.bullet-points li, .value-prop, .flow-step, .metric-category, .tech-component, .framework-item, .phase-card, .roi-metric, .challenge-category, .advantage, .timeline-item');
elements.forEach((element, index) => {
element.style.opacity = '0';
element.style.transform = 'translateY(20px)';
element.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
setTimeout(() => {
element.style.opacity = '1';
element.style.transform = 'translateY(0)';
}, 100 + (index * 100));
});
}
updateProgress() {
const progressBar = document.querySelector('.progress-indicator');
if (progressBar) {
const progress = ((this.currentSlide + 1) / this.totalSlides) * 100;
progressBar.style.width = `${progress}%`;
}
}
updateCounter() {
const currentSlideEl = document.getElementById('current-slide');
const totalSlidesEl = document.getElementById('total-slides');
if (currentSlideEl) currentSlideEl.textContent = this.currentSlide + 1;
if (totalSlidesEl) totalSlidesEl.textContent = this.totalSlides;
}
updateNavigationButtons() {
const prevBtn = document.getElementById('prev-slide');
const nextBtn = document.getElementById('next-slide');
if (prevBtn) {
prevBtn.disabled = this.currentSlide === 0;
}
if (nextBtn) {
nextBtn.disabled = this.currentSlide === this.totalSlides - 1;
// Update button text for last slide
if (this.currentSlide === this.totalSlides - 1) {
nextBtn.innerHTML = `
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M5 12h14M12 5l7 7-7 7"/>
</svg>
`;
nextBtn.setAttribute('aria-label', 'Finish presentation');
} else {
nextBtn.innerHTML = `
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M9 18l6-6-6-6"/>
</svg>
`;
nextBtn.setAttribute('aria-label', 'Next slide');
}
}
}
toggleFullscreen() {
if (!this.isFullscreen) {
this.enterFullscreen();
} else {
this.exitFullscreen();
}
}
enterFullscreen() {
const container = document.querySelector('.presentation-container');
if (container.requestFullscreen) {
container.requestFullscreen();
} else if (container.webkitRequestFullscreen) {
container.webkitRequestFullscreen();
} else if (container.mozRequestFullScreen) {
container.mozRequestFullScreen();
} else if (container.msRequestFullscreen) {
container.msRequestFullscreen();
}
}
exitFullscreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
}
handleFullscreenChange() {
const isFullscreen = !!(document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement ||
document.msFullscreenElement);
this.isFullscreen = isFullscreen;
this.updateFullscreenIcon();
const container = document.querySelector('.presentation-container');
if (container) {
if (isFullscreen) {
container.classList.add('fullscreen');
} else {
container.classList.remove('fullscreen');
}
}
}
updateFullscreenIcon() {
const icon = document.getElementById('fullscreen-icon');
if (icon) {
if (this.isFullscreen) {
icon.innerHTML = `
<path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"/>
`;
} else {
icon.innerHTML = `
<path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/>
`;
}
}
}
// Method to handle special slide interactions
initSlideInteractions() {
// Add click handlers for call-to-action buttons
const ctaButtons = document.querySelectorAll('.call-to-action .btn');
ctaButtons.forEach(button => {
button.addEventListener('click', (e) => {
e.preventDefault();
this.handleCTAClick(button.textContent.trim());
});
});
// Add hover effects for interactive elements
this.addHoverEffects();
}
handleCTAClick(buttonText) {
if (buttonText.includes('Schedule')) {
this.showNotification('Meeting request sent! Check your calendar for confirmation.');
} else if (buttonText.includes('Download')) {
this.showNotification('Strategy document download initiated.');
}
}
showNotification(message) {
// Create notification element
const notification = document.createElement('div');
notification.className = 'notification';
notification.style.cssText = `
position: fixed;
top: 20px;
right: 20px;
background-color: var(--color-success);
color: var(--color-btn-primary-text);
padding: 16px 24px;
border-radius: 8px;
font-size: 14px;
font-weight: 500;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
z-index: 1001;
opacity: 0;
transform: translateX(100%);
transition: all 0.3s ease;
`;
notification.textContent = message;
document.body.appendChild(notification);
// Animate in
setTimeout(() => {
notification.style.opacity = '1';
notification.style.transform = 'translateX(0)';
}, 100);
// Remove after 3 seconds
setTimeout(() => {
notification.style.opacity = '0';
notification.style.transform = 'translateX(100%)';
setTimeout(() => {
if (notification.parentNode) {
notification.parentNode.removeChild(notification);
}
}, 300);
}, 3000);
}
addHoverEffects() {
// Add hover effects to interactive elements
const interactiveElements = document.querySelectorAll('.value-prop, .tech-component, .framework-item, .advantage, .phase-card');
interactiveElements.forEach(element => {
element.addEventListener('mouseenter', () => {
element.style.transform = 'translateY(-5px)';
element.style.transition = 'transform 0.3s ease, box-shadow 0.3s ease';
element.style.boxShadow = 'var(--shadow-lg)';
});
element.addEventListener('mouseleave', () => {
element.style.transform = 'translateY(0)';
element.style.boxShadow = '';
});
});
}
// Method to handle slide-specific logic
handleSlideSpecifics(slideIndex) {
switch(slideIndex) {
case 0: // Title slide
setTimeout(() => this.animateTitleSlide(), 500);
break;
case 5: // Customer journey flow
setTimeout(() => this.animateFlowDiagram(), 500);
break;
case 11: // Business impact
setTimeout(() => this.animateROIMetrics(), 500);
break;
case 14: // Conclusion
setTimeout(() => this.initSlideInteractions(), 500);
break;
}
}
animateTitleSlide() {
const highlights = document.querySelectorAll('.highlight');
highlights.forEach((highlight, index) => {
highlight.style.opacity = '0';
highlight.style.transform = 'scale(0.8)';
highlight.style.transition = 'all 0.5s ease';
setTimeout(() => {
highlight.style.opacity = '1';
highlight.style.transform = 'scale(1)';
}, index * 200);
});
}
animateFlowDiagram() {
const steps = document.querySelectorAll('.flow-step');
steps.forEach((step, index) => {
step.style.opacity = '0';
step.style.transform = 'translateX(-50px)';
step.style.transition = 'all 0.5s ease';
setTimeout(() => {
step.style.opacity = '1';
step.style.transform = 'translateX(0)';
}, index * 300);
});
}
animateROIMetrics() {
const metrics = document.querySelectorAll('.roi-metric h3');
metrics.forEach((metric, index) => {
const finalValue = metric.textContent;
const isPercentage = finalValue.includes('%');
const numericValue = parseInt(finalValue.replace(/[^\d]/g, ''));
if (numericValue > 0) {
metric.textContent = isPercentage ? '0%' : '0';
setTimeout(() => {
this.animateNumber(metric, finalValue, numericValue, isPercentage);
}, index * 200);
}
});
}
animateNumber(element, finalValue, numericValue, isPercentage) {
let currentValue = 0;
const increment = Math.ceil(numericValue / 30);
const timer = setInterval(() => {
currentValue += increment;
if (currentValue >= numericValue) {
element.textContent = finalValue;
clearInterval(timer);
} else {
element.textContent = isPercentage ? `${currentValue}%` : `${currentValue}`;
}
}, 50);
}
}
// Initialize presentation when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
console.log('DOM loaded, initializing presentation...');
window.presentation = new Presentation();
});
// Fallback initialization for cases where DOMContentLoaded already fired
if (document.readyState !== 'loading') {
console.log('DOM already loaded, initializing presentation...');
window.presentation = new Presentation();
}
// Add global error handling
window.addEventListener('error', (e) => {
console.error('Presentation error:', e.error);
});
// Add performance optimization
window.addEventListener('load', () => {
console.log('Window loaded, optimizing...');
// Preload images
const images = document.querySelectorAll('img[src]');
images.forEach(img => {
const link = document.createElement('link');
link.rel = 'prefetch';
link.href = img.src;
document.head.appendChild(link);
});
});
// Add visibility change handling for presentations
document.addEventListener('visibilitychange', () => {
if (document.hidden) {
// Pause any ongoing animations when tab is not visible
document.querySelectorAll('.animate-in').forEach(el => {
if (el.style.animationPlayState !== undefined) {
el.style.animationPlayState = 'paused';
}
});
} else {
// Resume animations when tab becomes visible
document.querySelectorAll('.animate-in').forEach(el => {
if (el.style.animationPlayState !== undefined) {
el.style.animationPlayState = 'running';
}
});
}
});
// Export for potential external use
window.PresentationApp = Presentation; |