Gnarum | Empowering your energy

Employee Area

Technical Support

(function () { function initCF7FileUpload(scope) { // scope es opcional: si Elementor pasa el widget renderizado const context = scope || document; context.querySelectorAll('.custom-file-upload .file-input').forEach(input => { if (input.dataset.cf7Init) return; // evitar duplicados input.dataset.cf7Init = '1'; const wrapper = input.closest('.custom-file-upload'); if (!wrapper) return; const fileName = wrapper.querySelector('.file-name'); const fileIcon = wrapper.querySelector('.file-icon'); const buttonText = wrapper.querySelector('.file-button-text'); input.addEventListener('change', () => { if (!input.files || input.files.length === 0) { fileName.textContent = 'No hay archivo seleccionado'; fileIcon.textContent = '📎'; buttonText.textContent = 'Subir archivo'; return; } const file = input.files[0]; fileName.textContent = file.name; buttonText.textContent = 'Cambiar archivo'; const ext = file.name.split('.').pop().toLowerCase(); fileIcon.textContent = ext === 'pdf' ? '📄' : ext === 'doc' || ext === 'docx' ? '📝' : '📎'; }); }); } // Inicial cuando la página termina de cargar document.addEventListener('DOMContentLoaded', () => initCF7FileUpload()); // CF7 eventos document.addEventListener('wpcf7init', () => initCF7FileUpload()); document.addEventListener('wpcf7submit', () => initCF7FileUpload()); // Elementor widgets y popups if (window.elementorFrontend) { window.elementorFrontend.hooks.addAction('frontend/element_ready/global', (scope) => { initCF7FileUpload(scope); }); // Para popups que se abren dinámicamente window.elementorFrontend.hooks.addAction('frontend/element_ready/elementor-popup', (scope) => { initCF7FileUpload(scope); }); } })();