PageSourceSearch

https://highdeserthearing.com/wp-content/themes/Audire/dist/assets/js/wpcf7.js?ver=7.1.2

js highdeserthearing.com collected 2026-10-08 19:24:29 UTC 5,905 bytes, 167 lines download raw bytes

1/*-----------------------------------------------------------------------------------*/
2/*  Location Dropdown Support
3/*-----------------------------------------------------------------------------------*/
4
5function wad_enable_optgroups() {
6  let id = getWordpressPostId();
7  
8  // Convert optgroup tags into proper markup
9  var foundin = $('#wpsl-locations option:contains("optgroup-")');
10  $.each(foundin, function(value){
11    var updated = $(this).val().replace('optgroup-','');
12    $(this).nextUntil('option:contains("endoptgroup")').wrapAll('<optgroup label="'+updated+'"></optgroup>');
13  });
14  $('#wpsl-locations option:contains("optgroup-")').remove();
15  $('#wpsl-locations option:contains("endoptgroup")').remove();
16  
17  // Preselect element on WPSL store pages
18  const selectElement = document.getElementById('wpsl-locations');
19  if (selectElement) {
20    let selection = selectElement.querySelector('option[value="' + id + '"]');
21    if ( selection ) {
22      selectElement.value = id;
23      selection.setAttribute('selected', 'selected');
24    }
25  }
26}
27document.addEventListener('DOMContentLoaded', wad_enable_optgroups);
28
29/*-----------------------------------------------------------------------------------*/
30/*  Retrieve WP Post ID from page body class
31/*-----------------------------------------------------------------------------------*/
32
33function getWordpressPostId() {
34    let postID = null;
35    try {
36        document.getElementsByTagName("body")[0].classList.forEach((cls) => {
37            if(cls.startsWith("postid-")) {
38              postID = cls.split("-")[1];
39            }
40            
41            if(cls.startsWith("page-id-")) {
42              postID = cls.split("-")[2];
43            }
44        });
45    } catch(exc) {
46        // ... handle exception
47    }
48    return postID;
49}
50
51/*-----------------------------------------------------------------------------------*/
52/*  Detect and attempt to fix multiline labels
53/*-----------------------------------------------------------------------------------*/
54
55window.addEventListener( 'load', adjustMultilineLabels );
56window.addEventListener( 'resize', adjustMultilineLabels );
57
58function adjustMultilineLabels( e ) {
59  const adjust = 8;
60
61  var labels   = document.querySelectorAll('.form__label');
62  labels.forEach((label) => {
63    var { lineHeight }   = getComputedStyle(label);
64    var lineHeightParsed = parseInt(lineHeight.split('px')[0]);
65    
66    if ( label.scrollHeight > lineHeightParsed ) {
67      var group  = label.closest('.form__group');
68      var diff   = label.scrollHeight - lineHeightParsed + 1;
69      var adjustedMargin = label.scrollHeight + adjust;
70      
71      group.style.marginTop = adjustedMargin + "px";
72      label.style.top = "calc(var(--space-sm) * -2.5 - " + diff + "px)";
73    }
74  });
75}
76
77/*-----------------------------------------------------------------------------------*/
78/*  Submission Handler
79/*-----------------------------------------------------------------------------------*/
80
81document.addEventListener( 'wpcf7mailsent', async function( event ) {
82  const url = AUDIRE.homeUri + "/wp-json/audire/v1/contact-forms/submission/";
83  // console.log(event);
84  
85  let template = '';
86  for ( var i = 0; i < event.detail.inputs.length; i++ ) {
87    if ( event.detail.inputs[i].name == "response-message" ) {
88      template = event.detail.inputs[i].value;
89    }
90  }
91  if ( template == '' ) { template = 'default'; }
92  
93  try {
94    // console.log('Fetching ' + url + template);
95    const response = await fetch(url + template);
96    if (!response.ok) {
97      throw new Error(`Response status: ${response.status}`);
98    }
99  
100    const json = await response.json();
101    
102    // console.log(json);
103    
104    // Hide Existing Form Content
105    let formWrapper  = event.target.closest('.wpcf7--wrapper');
106    formWrapper.querySelector('.wpcf7-response-output').style.display = 'none';
107    for (const child of formWrapper.children) {
108      // child.style.opacity = 0.8;
109    }
110    
111    // Generate Response Message
112    let message = document.createElement("div");
113    message.classList.add("wpcf7--response-message");
114    
115    let responseContainer = document.createElement("div");
116    responseContainer.classList.add("wpcf7--response-message--container");
117    message.appendChild(responseContainer);
118    
119    let headline = document.createElement("p");
120    headline.classList.add("font-headline", "weight-500", "text-lg");
121    headline.textContent = json.headline;
122    responseContainer.appendChild(headline);
123    
124    let body = document.createElement("p");
125    /*
126    body.classList.add("text-md");
127    if ( formWrapper.classList.contains("text-white") ) {
128      body.classList.add("weight-500");
129    }
130    */
131    body.textContent = json.body;
132    responseContainer.appendChild(body);
133    
134    if ( json.link_to_homepage === true) {
135      let btns = document.createElement("p");
136      responseContainer.appendChild(btns);
137    
138      let homeBtn = document.createElement("a");
139      homeBtn.classList.add("btn", "form__button", "form__button--home");
140      homeBtn.textContent = "Back to Homepage";
141      homeBtn.href = AUDIRE.homeUri;
142      btns.appendChild(homeBtn);
143    }
144    
145    if ( json.hasOwnProperty("custom_link") && json.custom_link !== false ) {
146      let btns = document.createElement("p");
147      responseContainer.appendChild(btns);
148      
149      let theBtn = document.createElement("a");
150      theBtn.classList.add("btn", "form__button", "form__button--" + json.custom_link.class);
151      theBtn.textContent = json.custom_link.text;
152      
153      if ( json.custom_link.external == true) {
154        theBtn.href   = json.custom_link.url;
155        theBtn.target = "_blank";
156      } else {
157        theBtn.href = AUDIRE.homeUri + json.custom_link.url;
158      }
159      
160      btns.appendChild(theBtn);
161    }
162    
163    formWrapper.appendChild(message);
164  } catch (error) {
165    console.error(error.message);
166  }
167}, false );

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.