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
111 lines
No EOL
4.2 KiB
JavaScript
111 lines
No EOL
4.2 KiB
JavaScript
/**
|
|
* HVAC Trainer Dashboard JavaScript
|
|
*
|
|
* Handles dynamic filtering of events table and other interactive features.
|
|
*/
|
|
(function($) {
|
|
'use strict';
|
|
|
|
// Initialize the dashboard when DOM is ready
|
|
$(document).ready(function() {
|
|
initEventFilters();
|
|
});
|
|
|
|
/**
|
|
* Initialize event filters to work without page reload
|
|
*/
|
|
function initEventFilters() {
|
|
// Get the events table wrapper element
|
|
const $eventsTableWrapper = $('.hvac-events-table-wrapper');
|
|
|
|
// Add click handler to filter links
|
|
$('.hvac-event-filters a').on('click', function(e) {
|
|
e.preventDefault(); // Prevent default link behavior (page reload)
|
|
|
|
// Get the status filter from the link URL
|
|
const url = new URL($(this).attr('href'), window.location.origin);
|
|
const status = url.searchParams.get('event_status') || 'all';
|
|
|
|
// Update active class
|
|
$('.hvac-event-filters a').removeClass('hvac-filter-active ast-button-primary').addClass('ast-button-secondary');
|
|
$(this).addClass('hvac-filter-active ast-button-primary').removeClass('ast-button-secondary');
|
|
|
|
// Show loading indicator
|
|
$eventsTableWrapper.append('<div class="hvac-loading">Filtering events...</div>');
|
|
|
|
// Make AJAX request to get filtered events
|
|
$.ajax({
|
|
url: hvac_dashboard.ajax_url,
|
|
type: 'POST',
|
|
data: {
|
|
action: 'hvac_filter_events',
|
|
status: status,
|
|
nonce: hvac_dashboard.nonce
|
|
},
|
|
success: function(response) {
|
|
if (response.success) {
|
|
// Replace the table HTML with the filtered results
|
|
$eventsTableWrapper.html(response.data.html);
|
|
|
|
// Update the URL without reloading the page
|
|
if (history.pushState) {
|
|
const newUrl = status === 'all'
|
|
? removeURLParameter(window.location.href, 'event_status')
|
|
: addURLParameter(window.location.href, 'event_status', status);
|
|
window.history.pushState({ path: newUrl }, '', newUrl);
|
|
}
|
|
} else {
|
|
// Show error message
|
|
$eventsTableWrapper.find('.hvac-loading').remove();
|
|
$eventsTableWrapper.append('<div class="hvac-error">Error loading events: ' + response.data.message + '</div>');
|
|
}
|
|
},
|
|
error: function() {
|
|
// Show error message
|
|
$eventsTableWrapper.find('.hvac-loading').remove();
|
|
$eventsTableWrapper.append('<div class="hvac-error">Error communicating with server.</div>');
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Helper function to add a URL parameter
|
|
*/
|
|
function addURLParameter(url, key, value) {
|
|
const re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
|
|
const separator = url.indexOf('?') !== -1 ? "&" : "?";
|
|
|
|
if (url.match(re)) {
|
|
return url.replace(re, '$1' + key + "=" + value + '$2');
|
|
} else {
|
|
return url + separator + key + "=" + value;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Helper function to remove a URL parameter
|
|
*/
|
|
function removeURLParameter(url, parameter) {
|
|
const urlParts = url.split('?');
|
|
if (urlParts.length < 2) {
|
|
return url;
|
|
}
|
|
|
|
const urlBase = urlParts[0];
|
|
const queryString = urlParts[1];
|
|
const prefix = encodeURIComponent(parameter) + '=';
|
|
const parts = queryString.split(/[&;]/g);
|
|
|
|
// Reverse iteration to safely remove items
|
|
for (let i = parts.length; i-- > 0;) {
|
|
if (parts[i].lastIndexOf(prefix, 0) !== -1) {
|
|
parts.splice(i, 1);
|
|
}
|
|
}
|
|
|
|
const newQueryString = parts.join('&');
|
|
return newQueryString.length > 0 ? urlBase + '?' + newQueryString : urlBase;
|
|
}
|
|
|
|
})(jQuery); |