upskill-event-manager/assets/js/hvac-animations.js
Ben Reed cdc5ea85f4 feat: Add comprehensive CSS, JavaScript and theme asset infrastructure
Add massive collection of CSS, JavaScript and theme assets that were previously excluded:

**CSS Files (681 total):**
- HVAC plugin-specific styles (hvac-*.css): 34 files including dashboard, certificates, registration, mobile nav, accessibility fixes, animations, and welcome popup
- Theme framework files (Astra, builder systems, layouts): 200+ files
- Plugin compatibility styles (WooCommerce, WPForms, Elementor, Contact Form 7): 150+ files
- WordPress core and editor styles: 50+ files
- Responsive and RTL language support: 200+ files

**JavaScript Files (400+ total):**
- HVAC plugin functionality (hvac-*.js): 27 files including menu systems, dashboard enhancements, profile sharing, mobile responsive features, accessibility, and animations
- Framework and library files: jQuery plugins, GSAP, AOS, Swiper, Chart.js, Lottie, Isotope
- Plugin compatibility scripts: WPForms, WooCommerce, Elementor, Contact Form 7, LifterLMS
- WordPress core functionality: customizer, admin, block editor compatibility
- Third-party integrations: Stripe, SMTP, analytics, search functionality

**Assets:**
- Certificate background images and logos
- Comprehensive theme styling infrastructure
- Mobile-responsive design systems
- Cross-browser compatibility assets
- Performance-optimized minified versions

**Updated .gitignore:**
- Fixed asset directory whitelisting patterns to properly include CSS/JS/images
- Added proper directory structure recognition (!/assets/css/, !/assets/js/, etc.)
- Maintains security by excluding sensitive files while including essential assets

This commit provides the complete frontend infrastructure needed for:
- Full theme functionality and styling
- Plugin feature implementations
- Mobile responsiveness and accessibility
- Cross-browser compatibility
- Performance optimization
- Developer workflow support
2025-08-11 16:20:31 -03:00

143 lines
No EOL
5.9 KiB
JavaScript

/**
* HVAC Community Events Animation Helper
*
* This script adds animation support for dynamic elements and
* provides animation utility functions.
*/
(function() {
document.addEventListener('DOMContentLoaded', function() {
// Only run animations on HVAC pages
const isHVACPage = document.querySelector('.hvac-content') !== null;
if (!isHVACPage) {
return; // Exit early if not on an HVAC page
}
// Apply animations to elements with data-animate attribute
function animateElements() {
const elements = document.querySelectorAll('[data-animate]');
elements.forEach(element => {
const animationClass = element.getAttribute('data-animate');
const delay = element.getAttribute('data-animate-delay') || 0;
setTimeout(() => {
element.classList.add(animationClass);
element.style.opacity = '1';
}, delay);
});
}
// Initialize animations when page loads
animateElements();
// DISABLED - MutationObserver was causing Safari hanging issues
// The heavy DOM monitoring with childList: true, subtree: true
// creates excessive overhead that Safari's engine can't handle
/*
function setupMutationObserver() {
// Watch for new elements being added to the DOM
const observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
if (mutation.addedNodes && mutation.addedNodes.length > 0) {
// Check if any added node has animation attributes
mutation.addedNodes.forEach(node => {
// Skip non-element nodes
if (node.nodeType !== 1) return;
// Check for data-animate attribute
if (node.getAttribute('data-animate')) {
const animationClass = node.getAttribute('data-animate');
const delay = node.getAttribute('data-animate-delay') || 0;
setTimeout(() => {
node.classList.add(animationClass);
node.style.opacity = '1';
}, delay);
}
// Check children for data-animate attribute
const childElements = node.querySelectorAll('[data-animate]');
if (childElements.length > 0) {
childElements.forEach(element => {
const animationClass = element.getAttribute('data-animate');
const delay = element.getAttribute('data-animate-delay') || 0;
setTimeout(() => {
element.classList.add(animationClass);
element.style.opacity = '1';
}, delay);
});
}
});
}
});
});
// Start observing the document
observer.observe(document.body, {
childList: true,
subtree: true
});
}
// Start the observer - DISABLED
// setupMutationObserver();
*/
// Animate table rows in sequence - only on HVAC pages
function animateTableRows() {
// Only run on HVAC pages (check for hvac-content wrapper)
if (!document.querySelector('.hvac-content')) {
return;
}
const tables = document.querySelectorAll('.hvac-content .hvac-table, .hvac-content .events-table, .hvac-content .hvac-transactions-table');
tables.forEach(table => {
const rows = table.querySelectorAll('tbody tr');
rows.forEach((row, index) => {
row.style.opacity = '0';
setTimeout(() => {
row.classList.add('hvac-animate-slide-in-bottom');
row.style.opacity = '1';
}, 50 * (index + 1)); // Stagger animation
});
});
}
// Run table row animations
setTimeout(animateTableRows, 300);
// Add animation class to alerts and messages
const alerts = document.querySelectorAll('.hvac-alert, .hvac-email-sent, .hvac-email-error, .login-error, .hvac-errors, .hvac-success');
alerts.forEach(alert => {
alert.classList.add('hvac-animate-fade-in');
});
// Expose animation API to global scope
window.hvacAnimations = {
animateElement: function(element, animationClass, delay = 0) {
if (!element) return;
element.style.opacity = '0';
setTimeout(() => {
element.classList.add(animationClass);
element.style.opacity = '1';
}, delay);
},
animateElements: animateElements,
animateTableRows: animateTableRows
};
// Check if user prefers reduced motion
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if (prefersReducedMotion) {
document.body.classList.add('reduced-motion');
}
});
})();