PageSourceSearch

https://www.myheronhome.com/wp-content/cache/perfmatters/www.myher…8f2c2e7b49.customer-modal.min.js?ver=1.3.32

js myheronhome.com collected 2026-10-07 09:26:48 UTC 6,696 bytes, 30 lines download raw bytes

1(function(){'use strict';var DEBUG=(function(){try{if(/[?&]rtx-debug=1\b/.test(window.location.search))return!0;return window.localStorage.getItem('rtxDebug')==='1'}catch(e){return!1}}());function log(){if(!DEBUG)return;var args=Array.prototype.slice.call(arguments);args.unshift('[bug-hub:modal]');console.log.apply(console,args)}
2var modal=null;var lastFocusedElement=null;var activeField=null;function openModal(triggerEl){if(!modal)return;log('opening modal, triggered by',triggerEl);lastFocusedElement=triggerEl||document.activeElement;if(triggerEl&&triggerEl.closest){activeField=triggerEl.closest('.rtx-customer-type')}
3closeElementorPopup(triggerEl);updateQuiqAvailability();modal.setAttribute('aria-hidden','false');modal.classList.add('is-open');var firstFocusable=modal.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(firstFocusable)firstFocusable.focus();}
4function closeElementorPopup(triggerEl){if(!triggerEl||!triggerEl.closest)return;var popup=triggerEl.closest('.elementor-popup-modal');if(!popup)return;var closeBtn=popup.querySelector('.dialog-close-button');if(closeBtn)closeBtn.click();}
5function closeModal(){if(!modal)return;modal.setAttribute('aria-hidden','true');modal.classList.remove('is-open');resetActiveField();if(lastFocusedElement)lastFocusedElement.focus();}
6function resetActiveField(){if(!activeField)return;var select=activeField.querySelector('select');if(select){select.selectedIndex=0;select.dispatchEvent(new Event('change',{bubbles:!0}))}
7var radios=activeField.querySelectorAll('input[type="radio"]');if(radios.length){radios.forEach(function(radio){radio.checked=!1});radios[0].dispatchEvent(new Event('change',{bubbles:!0}))}
8activeField=null}
9function customerTypeValue(field){if(!field)return null;var select=field.querySelector('select');if(select)return select.value;var radio=field.querySelector('input[type="radio"]:checked');return radio?radio.value:null}
10function initForms(){document.addEventListener('change',function(e){var target=e.target;if(!target||!target.closest)return;var field=target.closest('.rtx-customer-type');if(!field)return;if(customerTypeValue(field)==='current_customer')openModal(target);})}
11function syncHeaderToPanel(){var inner=modal.querySelector('.rtx-modal-inner');if(!inner)return;var columns=modal.querySelectorAll('.rtx-modal-content .wp-block-column.has-background');if(!columns.length)return;var panel=columns[columns.length-1];var bg=window.getComputedStyle(panel).backgroundColor;if(bg&&bg!=='rgba(0, 0, 0, 0)'&&bg!=='transparent'){inner.style.setProperty('--rtx-panel-bg',bg)}}
12function quiqInstance(){var q=window.chat;return(q&&typeof q.getState==='function')?q:null}
13function quiqLauncher(){return document.querySelector('button.quiq-action-toggle')||document.querySelector('.quiq-floating-element [role="button"]')}
14function quiqWidgetEl(){return document.querySelector('.quiq-floating-element')}
15function openQuiqChat(){var quiq=quiqInstance();if(quiq&&typeof quiq.show==='function'){log('opening chat via window.chat.show()');quiq.show();return!0}
16var launcher=quiqLauncher();if(launcher){log('window.chat unavailable — opening chat by clicking Quiq launcher',launcher);launcher.click();return!0}
17log('cannot open chat: no window.chat API and no Quiq launcher in the DOM.','Quiq loaded?',!!window.Quiq,'| widget element?',!!quiqWidgetEl());return!1}
18function quiqAvailability(){var widget=quiqWidgetEl();if(!widget)return null;return widget.classList.contains('quiq-agent-available')}
19function applyAvailability(available,source){var buttons=modal.querySelectorAll('.quiq-custom-button');if(available===null||!buttons.length){log('availability unknown ('+source+') — leaving buttons as-is');return}
20log('agents available:',available,'(via '+source+')');buttons.forEach(function(btn){var pill=btn.closest('.rtx-contact-btn')||btn;pill.classList.toggle('rtx-chat-unavailable',!available)})}
21function updateQuiqAvailability(){var quiq=quiqInstance();if(!quiq){applyAvailability(quiqAvailability(),'DOM');return}
22quiq.getState().then(function(state){var widgets=(state&&state.widgets)||{};
22var keys=Object.keys(widgets);if(!keys.length){applyAvailability(null,'API: no widgets yet');return}
23var available=keys.some(function(key){return widgets[key]&&widgets[key].isChatAvailable});applyAvailability(available,'API')}).catch(function(err){log('chat.getState() rejected, falling back to DOM:',err);applyAvailability(quiqAvailability(),'DOM')})}
24function initQuiqAvailability(){var quiq=quiqInstance();var check=function(){updateQuiqAvailability();setTimeout(updateQuiqAvailability,5000)};if(quiq&&typeof quiq.waitForReady==='function'){quiq.waitForReady().then(check);return}
25if(quiq){check();return}
26var tries=0;var poll=setInterval(function(){tries++;if(quiqWidgetEl()||tries>20){clearInterval(poll);check()}},500)}
27function logQuiqDiagnostics(){if(!DEBUG)return;var snippet=Array.prototype.filter.call(document.querySelectorAll('script'),function(s){return/Quiq\(/.test(s.textContent||'')})[0];log('Quiq diagnostics:',{'window.chat':typeof window.chat,'window.chat.show':window.chat&&typeof window.chat.show,'window.Quiq loaded':typeof window.Quiq,'bootstrap script type':snippet?(snippet.getAttribute('type')||'(classic)'):'(not found)','launcher button in DOM':!!quiqLauncher(),'widget element in DOM':!!quiqWidgetEl(),'agent-available class':quiqAvailability(),'chat buttons in modal':modal.querySelectorAll('.quiq-custom-button').length});if(snippet&&snippet.getAttribute('type')==='module'){log('NOTE: the Quiq bootstrap runs as type="module", so its `var chat`'+' never reaches window. Using the launcher-click fallback.')}}
28function init(){modal=document.getElementById('rtx-customer-modal');if(!modal){log('no #rtx-customer-modal on this page — nothing to wire up');return}
29syncHeaderToPanel();initForms();initQuiqAvailability();logQuiqDiagnostics();modal.addEventListener('click',function(e){if(e.target.closest&&e.target.closest('.quiq-custom-button')){log('chat button clicked');if(openQuiqChat())closeModal();}});var closeBtn=modal.querySelector('.rtx-modal-close');var backBtn=modal.querySelector('.rtx-modal-back');if(closeBtn)closeBtn.addEventListener('click',closeModal);if(backBtn)backBtn.addEventListener('click',closeModal);modal.addEventListener('click',function(e){if(e.target===modal)closeModal();});document.addEventListener('keydown',function(e){if(e.key==='Escape'&&modal.classList.contains('is-open'))closeModal();})}
30if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',init)}else{log('script ran after DOMContentLoaded (readyState: '+document.readyState+') — initialising immediately');init()}}())

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.