fix: Properly resolve home page content disappearing issue

- Made CSS animations specific to .hvac-content wrapper to prevent affecting non-HVAC pages
- Added JavaScript safety checks to only run animations on HVAC pages
- Fixed overly broad CSS selectors that were hiding content globally
- Added early return in JavaScript if not on HVAC page
- Fixed animation table row selectors to be HVAC-specific

The root cause was CSS/JS affecting elements with generic class names site-wide.
Now animations only target elements within HVAC plugin pages.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
bengizmo 2025-05-24 08:41:49 -03:00
parent e95191f919
commit 29c1d88082
3 changed files with 105 additions and 89 deletions

View file

@ -219,14 +219,14 @@
animation: slide-in-bottom 0.3s ease-out 0.3s both;
}
/* Initial loading state for animated elements */
.hvac-animate-fade-in,
.hvac-animate-scale-up,
.hvac-animate-slide-in-right,
.hvac-animate-slide-in-left,
.hvac-animate-slide-in-bottom,
.hvac-dashboard-stats .hvac-stat-card,
.hvac-event-summary-stats .hvac-event-stat-card {
/* Initial loading state for animated elements - only on HVAC pages */
.hvac-content .hvac-animate-fade-in,
.hvac-content .hvac-animate-scale-up,
.hvac-content .hvac-animate-slide-in-right,
.hvac-content .hvac-animate-slide-in-left,
.hvac-content .hvac-animate-slide-in-bottom,
.hvac-content .hvac-dashboard-stats .hvac-stat-card,
.hvac-content .hvac-event-summary-stats .hvac-event-stat-card {
opacity: 0;
}
@ -238,13 +238,13 @@
transition-duration: 0.001s !important;
}
.hvac-animate-fade-in,
.hvac-animate-scale-up,
.hvac-animate-slide-in-right,
.hvac-animate-slide-in-left,
.hvac-animate-slide-in-bottom,
.hvac-dashboard-stats .hvac-stat-card,
.hvac-event-summary-stats .hvac-event-stat-card {
.hvac-content .hvac-animate-fade-in,
.hvac-content .hvac-animate-scale-up,
.hvac-content .hvac-animate-slide-in-right,
.hvac-content .hvac-animate-slide-in-left,
.hvac-content .hvac-animate-slide-in-bottom,
.hvac-content .hvac-dashboard-stats .hvac-stat-card,
.hvac-content .hvac-event-summary-stats .hvac-event-stat-card {
opacity: 1;
}
}

View file

@ -7,6 +7,12 @@
(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]');
@ -75,9 +81,14 @@
// Start the observer
setupMutationObserver();
// Animate table rows in sequence
// Animate table rows in sequence - only on HVAC pages
function animateTableRows() {
const tables = document.querySelectorAll('.hvac-table, .events-table, .hvac-transactions-table');
// 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');

View file

@ -220,86 +220,91 @@ register_deactivation_hook(__FILE__, 'hvac_ce_remove_roles');
* Enqueue common styles and scripts for HVAC Community Events pages
*/
function hvac_ce_enqueue_common_assets() {
// Check if we're on an HVAC plugin page to prevent conflicts with home page
// Early return if not on HVAC pages to prevent loading on home page
if (is_front_page() || is_home()) {
return;
}
// Check if we're on an HVAC plugin page
$hvac_pages = [
'hvac-dashboard', 'community-login', 'trainer-registration', 'trainer-profile',
'manage-event', 'event-summary', 'email-attendees', 'certificate-reports',
'generate-certificates', 'certificate-fix', 'hvac-documentation'
];
$is_hvac_page = is_page($hvac_pages) || is_user_logged_in() && current_user_can('hvac_trainer');
// Only load framework styles globally (these are safe and minimal)
if ($is_hvac_page) {
// Enqueue the harmonized framework first - this provides the base styling
wp_enqueue_style(
'hvac-harmonized-framework',
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-harmonized.css',
[], // No dependencies - this is the foundation
HVAC_CE_VERSION . '-v3.0.0'
);
// Enqueue the legacy common CSS file for backward compatibility
wp_enqueue_style(
'hvac-common-style',
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-common.css',
['hvac-harmonized-framework'], // Depends on harmonized framework
HVAC_CE_VERSION
);
// Enqueue animations CSS file (ONLY on HVAC pages)
wp_enqueue_style(
'hvac-animations',
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-animations.css',
['hvac-harmonized-framework'], // Depends on harmonized framework
HVAC_CE_VERSION
);
// Enqueue mobile navigation CSS file (ONLY on HVAC pages)
wp_enqueue_style(
'hvac-mobile-nav',
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-mobile-nav.css',
['hvac-harmonized-framework'], // Depends on harmonized framework
HVAC_CE_VERSION
);
// Enqueue print stylesheet
wp_enqueue_style(
'hvac-print-style',
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-print.css',
['hvac-harmonized-framework'], // Depends on harmonized framework
HVAC_CE_VERSION,
'print' // Print media only
);
// Enqueue the accessibility helper JS (ONLY on HVAC pages)
wp_enqueue_script(
'hvac-accessibility-js',
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-accessibility.js',
[], // No dependencies
HVAC_CE_VERSION,
true // Load in footer
);
// Enqueue animations JS (ONLY on HVAC pages)
wp_enqueue_script(
'hvac-animations-js',
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-animations.js',
[], // No dependencies
HVAC_CE_VERSION,
true // Load in footer
);
// Enqueue mobile navigation JS (ONLY on HVAC pages)
wp_enqueue_script(
'hvac-mobile-nav-js',
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-mobile-nav.js',
[], // No dependencies
HVAC_CE_VERSION,
true // Load in footer
);
// Only proceed if we're on an HVAC page
if (!is_page($hvac_pages)) {
return;
}
// Enqueue the harmonized framework first - this provides the base styling
wp_enqueue_style(
'hvac-harmonized-framework',
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-harmonized.css',
[], // No dependencies - this is the foundation
HVAC_CE_VERSION . '-v3.0.0'
);
// Enqueue the legacy common CSS file for backward compatibility
wp_enqueue_style(
'hvac-common-style',
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-common.css',
['hvac-harmonized-framework'], // Depends on harmonized framework
HVAC_CE_VERSION
);
// Enqueue animations CSS file (ONLY on HVAC pages)
wp_enqueue_style(
'hvac-animations',
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-animations.css',
['hvac-harmonized-framework'], // Depends on harmonized framework
HVAC_CE_VERSION
);
// Enqueue mobile navigation CSS file (ONLY on HVAC pages)
wp_enqueue_style(
'hvac-mobile-nav',
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-mobile-nav.css',
['hvac-harmonized-framework'], // Depends on harmonized framework
HVAC_CE_VERSION
);
// Enqueue print stylesheet
wp_enqueue_style(
'hvac-print-style',
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-print.css',
['hvac-harmonized-framework'], // Depends on harmonized framework
HVAC_CE_VERSION,
'print' // Print media only
);
// Enqueue the accessibility helper JS (ONLY on HVAC pages)
wp_enqueue_script(
'hvac-accessibility-js',
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-accessibility.js',
[], // No dependencies
HVAC_CE_VERSION,
true // Load in footer
);
// Enqueue animations JS (ONLY on HVAC pages)
wp_enqueue_script(
'hvac-animations-js',
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-animations.js',
[], // No dependencies
HVAC_CE_VERSION,
true // Load in footer
);
// Enqueue mobile navigation JS (ONLY on HVAC pages)
wp_enqueue_script(
'hvac-mobile-nav-js',
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-mobile-nav.js',
[], // No dependencies
HVAC_CE_VERSION,
true // Load in footer
);
// Enqueue page-specific enhanced styles based on current page
if (is_page('hvac-dashboard')) {
wp_enqueue_style(