Dave and Co Metals - Header
Premium Bullion • Limited-Time Savings • Apply DAVE78 and save 5 TO 10% today.

Valcambi Platinum Bar

Showing the single result

Shopping Cart
/* ======================================== DAVE AND CO METALS - MOBILE FIX v4 (BULLETPROOF) Designed to run even with conflicting scripts ======================================== */(function() { 'use strict';try { console.log('🚀 Mobile Responsive Fix v4 - BULLETPROOF - Starting...');// Immediate fixes - run ASAP document.documentElement.style.overflowX = 'hidden'; document.body.style.overflowX = 'hidden'; document.body.style.width = '100%'; document.body.style.maxWidth = '100%';// Check if device is mobile function isMobile() { return window.innerWidth <= 768; }// INJECT CRITICAL CSS - This is the key fix function injectCriticalCSS() { const styleId = 'mobile-fix-critical-v4'; if (document.getElementById(styleId)) return;const style = document.createElement('style'); style.id = styleId; style.textContent = ` /* BULLETPROOF MOBILE FIX */ html { overflow-x: hidden !important; width: 100% !important; } body { overflow-x: hidden !important; width: 100% !important; max-width: 100% !important; margin: 0 !important; padding: 0 !important; }/* ALL IMAGES */ img { max-width: 100% !important; height: auto !important; display: block !important; }/* CONTAINERS */ .elementor-container { max-width: 100% !important; width: 100% !important; } .elementor-section { width: 100% !important; max-width: 100% !important; } .elementor-column { width: 100% !important; max-width: 100% !important; } .elementor-widget { max-width: 100% !important; width: 100% !important; } .elementor-row { overflow-x: hidden !important; width: 100% !important; } .elementor-widget-wrap { overflow-x: hidden !important; }/* PRODUCTS */ .woocommerce ul.products { display: grid !important; grid-template-columns: 1fr !important; width: 100% !important; gap: 0 !important; } .woocommerce ul.products li { width: 100% !important; margin: 0 !important; margin-bottom: 20px !important; } .woocommerce ul.products li img { max-width: 100% !important; height: auto !important; }/* REMOVE FIXED WIDTHS */ [style*="width: 1200px"] { width: 100% !important; max-width: 100% !important; } [style*="width: 1000px"] { width: 100% !important; max-width: 100% !important; } [style*="width: 900px"] { width: 100% !important; max-width: 100% !important; } [style*="width: 800px"] { width: 100% !important; max-width: 100% !important; }/* MOBILE */ @media (max-width: 768px) { .elementor-container { max-width: 100% !important; width: 100% !important; padding: 0 15px !important; } .woocommerce ul.products li { width: 100% !important; } .elementor-column { width: 100% !important; } img { max-width: 100% !important; height: auto !important; } } `; document.head.appendChild(style); console.log('✅ Critical CSS injected'); }// Force all images to be responsive function fixAllImages() { try { const images = document.querySelectorAll('img'); let count = 0; images.forEach(img => { img.style.maxWidth = '100%'; img.style.height = 'auto'; img.style.width = 'auto'; img.style.display = 'block'; if (!img.loading) img.loading = 'lazy'; count++; }); if (count > 0) console.log(`✅ Fixed ${count} images`); } catch (e) { console.warn('⚠️ Error fixing images:', e.message); } }// Strip inline width styles that break layout function stripWidths() { try { const elements = document.querySelectorAll('[style*="width"]'); let count = 0; elements.forEach(el => { const style = el.getAttribute('style'); if (style && /width:\s*\d{3,4}px/i.test(style)) { const newStyle = style .replace(/width:\s*\d+px\s*!important;?/gi, '') .replace(/width:\s*\d+px;?/gi, ''); if (newStyle.trim()) { el.setAttribute('style', newStyle); } else { el.removeAttribute('style'); } count++; } }); if (count > 0) console.log(`✅ Stripped ${count} inline widths`); } catch (e) { console.warn('⚠️ Error stripping widths:', e.message); } }// Force product grids to stack function fixProductGrids() { try { const products = document.querySelectorAll('.woocommerce ul.products li'); products.forEach(p => { p.style.width = '100%'; p.style.margin = '0'; p.style.marginBottom = '20px'; }); if (products.length > 0) console.log(`✅ Fixed ${products.length} product items`); } catch (e) { console.warn('⚠️ Error fixing product grids:', e.message); } }// Force containers function fixContainers() { try { const containers = document.querySelectorAll('.elementor-container, .container'); containers.forEach(c => { c.style.maxWidth = '100%'; c.style.width = '100%'; c.style.overflowX = 'hidden'; }); if (containers.length > 0) console.log(`✅ Fixed ${containers.length} containers`); } catch (e) { console.warn('⚠️ Error fixing containers:', e.message); } }// Main function to run all fixes function runAllFixes() { console.log('🔧 Running all fixes...'); try { injectCriticalCSS(); fixAllImages(); stripWidths(); fixProductGrids(); fixContainers(); console.log('✅ ALL FIXES COMPLETE'); } catch (e) { console.error('❌ Critical error:', e); } }// Run immediately runAllFixes();// Run on DOMContentLoaded if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', runAllFixes); }// Run after delays to catch Elementor rendering setTimeout(runAllFixes, 500); setTimeout(runAllFixes, 1000); setTimeout(runAllFixes, 2000);// Watch for new content try { const observer = new MutationObserver(() => { fixAllImages(); stripWidths(); }); observer.observe(document.body, { childList: true, subtree: true }); console.log('✅ Mutation observer active'); } catch (e) { console.warn('⚠️ Could not set up observer:', e.message); }// Listen for resize window.addEventListener('resize', () => { if (isMobile()) { fixAllImages(); fixProductGrids(); } });console.log('✅ Mobile Responsive Fix v4 - Ready'); } catch (error) { console.error('❌ FATAL ERROR in Mobile Responsive Fix:', error); } })();