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:
parent
e95191f919
commit
29c1d88082
3 changed files with 105 additions and 89 deletions
|
|
@ -219,14 +219,14 @@
|
||||||
animation: slide-in-bottom 0.3s ease-out 0.3s both;
|
animation: slide-in-bottom 0.3s ease-out 0.3s both;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initial loading state for animated elements */
|
/* Initial loading state for animated elements - only on HVAC pages */
|
||||||
.hvac-animate-fade-in,
|
.hvac-content .hvac-animate-fade-in,
|
||||||
.hvac-animate-scale-up,
|
.hvac-content .hvac-animate-scale-up,
|
||||||
.hvac-animate-slide-in-right,
|
.hvac-content .hvac-animate-slide-in-right,
|
||||||
.hvac-animate-slide-in-left,
|
.hvac-content .hvac-animate-slide-in-left,
|
||||||
.hvac-animate-slide-in-bottom,
|
.hvac-content .hvac-animate-slide-in-bottom,
|
||||||
.hvac-dashboard-stats .hvac-stat-card,
|
.hvac-content .hvac-dashboard-stats .hvac-stat-card,
|
||||||
.hvac-event-summary-stats .hvac-event-stat-card {
|
.hvac-content .hvac-event-summary-stats .hvac-event-stat-card {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -238,13 +238,13 @@
|
||||||
transition-duration: 0.001s !important;
|
transition-duration: 0.001s !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hvac-animate-fade-in,
|
.hvac-content .hvac-animate-fade-in,
|
||||||
.hvac-animate-scale-up,
|
.hvac-content .hvac-animate-scale-up,
|
||||||
.hvac-animate-slide-in-right,
|
.hvac-content .hvac-animate-slide-in-right,
|
||||||
.hvac-animate-slide-in-left,
|
.hvac-content .hvac-animate-slide-in-left,
|
||||||
.hvac-animate-slide-in-bottom,
|
.hvac-content .hvac-animate-slide-in-bottom,
|
||||||
.hvac-dashboard-stats .hvac-stat-card,
|
.hvac-content .hvac-dashboard-stats .hvac-stat-card,
|
||||||
.hvac-event-summary-stats .hvac-event-stat-card {
|
.hvac-content .hvac-event-summary-stats .hvac-event-stat-card {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,6 +7,12 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
document.addEventListener('DOMContentLoaded', 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
|
// Apply animations to elements with data-animate attribute
|
||||||
function animateElements() {
|
function animateElements() {
|
||||||
const elements = document.querySelectorAll('[data-animate]');
|
const elements = document.querySelectorAll('[data-animate]');
|
||||||
|
|
@ -75,9 +81,14 @@
|
||||||
// Start the observer
|
// Start the observer
|
||||||
setupMutationObserver();
|
setupMutationObserver();
|
||||||
|
|
||||||
// Animate table rows in sequence
|
// Animate table rows in sequence - only on HVAC pages
|
||||||
function animateTableRows() {
|
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 => {
|
tables.forEach(table => {
|
||||||
const rows = table.querySelectorAll('tbody tr');
|
const rows = table.querySelectorAll('tbody tr');
|
||||||
|
|
|
||||||
|
|
@ -220,17 +220,23 @@ register_deactivation_hook(__FILE__, 'hvac_ce_remove_roles');
|
||||||
* Enqueue common styles and scripts for HVAC Community Events pages
|
* Enqueue common styles and scripts for HVAC Community Events pages
|
||||||
*/
|
*/
|
||||||
function hvac_ce_enqueue_common_assets() {
|
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_pages = [
|
||||||
'hvac-dashboard', 'community-login', 'trainer-registration', 'trainer-profile',
|
'hvac-dashboard', 'community-login', 'trainer-registration', 'trainer-profile',
|
||||||
'manage-event', 'event-summary', 'email-attendees', 'certificate-reports',
|
'manage-event', 'event-summary', 'email-attendees', 'certificate-reports',
|
||||||
'generate-certificates', 'certificate-fix', 'hvac-documentation'
|
'generate-certificates', 'certificate-fix', 'hvac-documentation'
|
||||||
];
|
];
|
||||||
|
|
||||||
$is_hvac_page = is_page($hvac_pages) || is_user_logged_in() && current_user_can('hvac_trainer');
|
// Only proceed if we're on an HVAC page
|
||||||
|
if (!is_page($hvac_pages)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Only load framework styles globally (these are safe and minimal)
|
|
||||||
if ($is_hvac_page) {
|
|
||||||
// Enqueue the harmonized framework first - this provides the base styling
|
// Enqueue the harmonized framework first - this provides the base styling
|
||||||
wp_enqueue_style(
|
wp_enqueue_style(
|
||||||
'hvac-harmonized-framework',
|
'hvac-harmonized-framework',
|
||||||
|
|
@ -298,7 +304,6 @@ function hvac_ce_enqueue_common_assets() {
|
||||||
HVAC_CE_VERSION,
|
HVAC_CE_VERSION,
|
||||||
true // Load in footer
|
true // Load in footer
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
// Enqueue page-specific enhanced styles based on current page
|
// Enqueue page-specific enhanced styles based on current page
|
||||||
if (is_page('hvac-dashboard')) {
|
if (is_page('hvac-dashboard')) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue