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
176 lines
No EOL
5.6 KiB
JavaScript
176 lines
No EOL
5.6 KiB
JavaScript
/**
|
|
* HVAC Menu System JavaScript
|
|
* Handle dropdown interactions and mobile menu behavior
|
|
*/
|
|
|
|
(function($) {
|
|
'use strict';
|
|
|
|
/**
|
|
* Initialize menu system
|
|
*/
|
|
function initHVACMenu() {
|
|
const $menu = $('.hvac-trainer-menu');
|
|
|
|
if (!$menu.length) {
|
|
return;
|
|
}
|
|
|
|
// Handle dropdown toggles
|
|
handleDropdownToggles($menu);
|
|
|
|
// Handle outside clicks to close dropdowns
|
|
handleOutsideClicks($menu);
|
|
|
|
// Handle keyboard navigation
|
|
handleKeyboardNavigation($menu);
|
|
|
|
// Highlight current page
|
|
highlightCurrentPage($menu);
|
|
}
|
|
|
|
/**
|
|
* Handle dropdown toggle clicks
|
|
*/
|
|
function handleDropdownToggles($menu) {
|
|
$menu.find('.menu-toggle').on('click', function(e) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
|
|
const $menuItem = $(this).closest('.menu-item');
|
|
const $parentMenu = $menuItem.closest('.hvac-trainer-menu, .sub-menu');
|
|
|
|
// Close other open menus at the same level
|
|
$parentMenu.find('> .menu-item.has-children.open').not($menuItem).removeClass('open');
|
|
|
|
// Toggle current menu
|
|
$menuItem.toggleClass('open');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Handle clicks outside menu to close dropdowns
|
|
*/
|
|
function handleOutsideClicks($menu) {
|
|
$(document).on('click.hvacMenu', function(e) {
|
|
if (!$(e.target).closest('.hvac-trainer-menu-wrapper').length) {
|
|
$menu.find('.menu-item.has-children.open').removeClass('open');
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Handle keyboard navigation
|
|
*/
|
|
function handleKeyboardNavigation($menu) {
|
|
$menu.find('a, .menu-toggle').on('keydown', function(e) {
|
|
const $current = $(this);
|
|
const $menuItem = $current.closest('.menu-item');
|
|
|
|
switch(e.which) {
|
|
case 13: // Enter
|
|
if ($current.hasClass('menu-toggle')) {
|
|
e.preventDefault();
|
|
$current.click();
|
|
}
|
|
break;
|
|
|
|
case 27: // Escape
|
|
$menu.find('.menu-item.has-children.open').removeClass('open');
|
|
$current.blur();
|
|
break;
|
|
|
|
case 37: // Left arrow
|
|
if ($menuItem.closest('.sub-menu').length) {
|
|
e.preventDefault();
|
|
$menuItem.closest('.has-children').removeClass('open');
|
|
$menuItem.closest('.has-children').find('> .menu-toggle, > a').focus();
|
|
}
|
|
break;
|
|
|
|
case 39: // Right arrow
|
|
if ($menuItem.hasClass('has-children')) {
|
|
e.preventDefault();
|
|
$menuItem.addClass('open');
|
|
$menuItem.find('.sub-menu > .menu-item:first-child > a').focus();
|
|
}
|
|
break;
|
|
|
|
case 38: // Up arrow
|
|
e.preventDefault();
|
|
navigateVertically($current, 'up');
|
|
break;
|
|
|
|
case 40: // Down arrow
|
|
e.preventDefault();
|
|
navigateVertically($current, 'down');
|
|
break;
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Navigate vertically through menu items
|
|
*/
|
|
function navigateVertically($current, direction) {
|
|
const $menuItem = $current.closest('.menu-item');
|
|
const $parentMenu = $menuItem.closest('.hvac-trainer-menu, .sub-menu');
|
|
const $siblings = $parentMenu.find('> .menu-item');
|
|
const currentIndex = $siblings.index($menuItem);
|
|
|
|
let targetIndex;
|
|
if (direction === 'down') {
|
|
targetIndex = currentIndex + 1;
|
|
if (targetIndex >= $siblings.length) targetIndex = 0;
|
|
} else {
|
|
targetIndex = currentIndex - 1;
|
|
if (targetIndex < 0) targetIndex = $siblings.length - 1;
|
|
}
|
|
|
|
const $target = $siblings.eq(targetIndex);
|
|
$target.find('> a, > .menu-toggle').focus();
|
|
}
|
|
|
|
/**
|
|
* Highlight current page in menu
|
|
*/
|
|
function highlightCurrentPage($menu) {
|
|
const currentUrl = window.location.pathname;
|
|
|
|
$menu.find('a').each(function() {
|
|
const $link = $(this);
|
|
const linkUrl = $link.attr('href');
|
|
|
|
if (linkUrl && linkUrl !== '#') {
|
|
const linkPath = linkUrl.replace(window.location.origin, '');
|
|
|
|
if (currentUrl === linkPath ||
|
|
(linkPath !== '/' && currentUrl.indexOf(linkPath) === 0)) {
|
|
$link.closest('.menu-item').addClass('current-menu-item');
|
|
|
|
// Also mark parent items
|
|
$link.closest('.sub-menu').closest('.menu-item').addClass('current-menu-parent');
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Clean up event handlers
|
|
*/
|
|
function cleanupHVACMenu() {
|
|
$(document).off('click.hvacMenu');
|
|
}
|
|
|
|
// Initialize when DOM is ready
|
|
$(document).ready(function() {
|
|
initHVACMenu();
|
|
});
|
|
|
|
// Reinitialize on AJAX content updates
|
|
$(document).on('hvac-content-updated', function() {
|
|
cleanupHVACMenu();
|
|
initHVACMenu();
|
|
});
|
|
|
|
})(jQuery); |