1var countryStates = {}; 2 3$(document).ready(function () { 4 afterFormLoad(); 5 setActiveMenu(); 6 setProgressStepsCount(); 7 $("button.previous-button").click(function (e) { 8 e.preventDefault(); 9 window.location = $(this).attr('data-ref'); 10 }); 11 $(".switch-language").on('click', function (e) { 12 var rel = this.getAttribute('rel') || ''; 13 if (rel.length > 0) { 14 e.preventDefault(); 15 var pathname = window.location.pathname.split('/'); 16 pathname[1] = rel; 17 window.location.pathname = pathname.join('/'); 18 } 19 }); 20 $('.select-country').each(function () { 21 var stateElement = $(this).closest('form').find('[name="' + $(this).find('.form-control').attr('name').replace(/country(?!.*country)/, 'state') + '"]'); 22 if (stateElement.length) { 23 var countryVal = $(this).find('.form-control').val(); 24 manageSelectState(countryVal, stateElement); 25 } 26 }); 27 HPJForm.datePicker(); 28 $(document).find('form[dynamic]').each(function () { 29 try { 30 $(this).find('.has-error:eq(0)').each(function () { 31 window.scrollTo(0, $(this).offset().top - 50); 32 }); 33 } catch (e) { 34 console.log(e); 35 } 36 }); 37 setTimeout(function () { 38 $('.site_line__item.hide').remove(); 39 }, 1000); 40}).on('change', '.select-country', function () { 41 var stateElement = $(this).closest('form') 42 .find('[name="' + $(this).find('.form-control').attr('name').replace(/country(?!.*country)/, 'state') + '"]'); 43 if (stateElement.length) { 44 var countryVal = $(this).find('.form-control').val(); 45 manageSelectState(countryVal, stateElement); 46 } 47}); 48 49/** 50 * Set Class active on the correct menu element 51 */ 52function setActiveMenu() { 53 var li = $("li[rel='data-menu-" + pageId + "']"); 54 if (li.length !== 0) { 55 li.addClass('active'); 56 } else { 57 li = $("li[rel='data-children-" + pageId + "']"); 58 li.parent().parent().addClass('active'); 59 } 60} 61 62/** 63 * Set count of steps for progress steps nav 64 */ 65function setProgressStepsCount() { 66 var nav_progress_steps = $('.nav-progress-steps'); 67 if (nav_progress_steps.length) { 68 nav_progress_steps.addClass('nav-steps-' + $('> li:visible', nav_progress_steps).length); 69 } 70} 71 72function manageSelectState(countryVal, stateElement) { 73 let stateElementId = stateElement.attr('id'); 74 let stateElementName = stateElement.attr('name'); 75 let newStateElement = null; 76 if (['CA', 'US', 'IT'].includes(countryVal)) { 77 newStateElement = $('<select name="' + stateElementName + '" id="' + stateElementId + '" class="form-control">'); 78 let defaultState = stateElement.get(0).closest('.form-group').dataset.default; 79 if (stateElement.val() != null) { 80 defaultState = stateElement.val(); 81 } 82 stateElement.closest('.form-group').show(); 83 stateElement.replaceWith(newStateElement); 84 getStatesV2(countryVal, newStateElement, defaultState); 85 } else { 86 newStateElement = $('<input name="' + stateElementName + '" id="' + stateElementId + '" type="hidden" class="form-control input-md">'); 87 if (typeof stateElementDefault != 'undefined') { 88 newStateElement.attr('refDefault', stateElementDefault); 89 } 90 stateElement.closest('.form-group').hide(); 91 stateElement.replaceWith(newStateElement); 92 } 93} 94 95function getStatesV2(country, stateElement, defaultValue, callback) { 96 if (!['CA', 'US', 'IT'].includes(country)) { 97 stateElement.empty(); 98 if (stateElement.next('.chosen-container').length) { 99 stateElement.trigger('chosen:updated'); 100 } 101 return; 102 } 103 if (typeof countryStates[country] === 'undefined') { 104 countryStates[country] = {ajax: 1, data: {}}; 105 var url = '/form/' + language + '/form/getstates/'; 106 if ($('body > #site-wrapper').length) { 107 url = '/' + language + '/method/ajax-get-states/name/module/'; 108 } 109 $.ajax({ 110 url: url, 111 type: "GET", 112 async: "false", 113 global: false, 114 dataType: "json", 115 data: {country: country}, 116 success: function (data) { 117 countryStates[country].data = data; 118 }, 119 complete: function () { 120 countryStates[country].ajax = 0; 121 } 122 }); 123 } 124 125 if (countryStates[country].ajax === 1) { 126 setTimeout(function () { 127 getStatesV2(country, stateElement, defaultValue, callback) 128 }, 500); 129 } else { 130 const jsSelect = stateElement.get(0); 131 132 stateElement.empty(); 133 134 const selectText = jsSelect.closest('.form-group').dataset.selectText; 135 136 if (selectText) { 137 stateElement.append($('<option value="">' + selectText + '</option>')); 138 } 139 140 $.each(countryStates[country].data, function (key, value) { 141 stateElement.append( 142 $('<option value="' + key + '">' + value + '</option>') 143 ); 144 }); 145 146 if (!defaultValue) { 147 defaultValue = jsSelect.closest('.form-group').dataset.default; 148 } 149 150 if (defaultValue) { 151 const optionToSelect = Array.from(jsSelect.options).find(option => option.value === defaultValue); 152 if (optionToSelect) { 153 optionToSelect.selected = true; 154 } 155 } 156 157 if (typeof callback === 'function') { 158 callback(stateElement); 159 } 160 } 161} 162 163window.addEventListener('message', function (e) { 164 try { 165 if (e.data == 'previewZone') { 166 $(".site_line__item").show(); 167 $('[data-line-id="system"]').remove(); 168 $(".site-inner div[data-zone-alias]").each(function () { 169 if (!$(this).find('.zone-selectable-name').length) { 170 $(this).addClass("web__zone__selected") 171 .prepend( 172 $('<div />', { 173 class: "zone-selectable-name", 174 style: "position:absolute;bottom:0;top:0;left:0;right:0;z-index:99999;" 175 }) 176 .append( 177 $(this).data("zone-alias"), 178 $('<span />', {class: "zone-selectable-name__btn-edit"}).append($('<i />', {class: "icon icon-pencil"}), text_edit) 179 ) 180 ); 181 } 182 }); 183 $(document).off('click', '.site-inner div[data-zone-alias]') 184 .on('click', '.site-inner div[data-zone-alias]', function () { 185 parent.postMessage({zoneid: $(this).attr('id')}, "*"); 186 }) 187 } 188 } catch (e) { 189 } 190}, false); 191 192function afterFormLoad(form) { 193 $(form || document) 194 .find("label.required,label>span.required").each(function (index) { 195 if ($(this).text().indexOf("*") == -1) { 196 var html = $(this).html(); 197 if (html.indexOf("<") !== -1) { 198 html = html.slice(0, html.indexOf("<")) + '<span class="control-label--required"> *</span>' + html.slice(html.indexOf("<")); 199 $(this).html(html); 200 } else { 201 $(this).append('<span class="control-label--required"> *</span>'); 202 } 203 } 204 }); 205 206 $('[data-conditional-field],[data-display-conditions]').trigger('change'); 207 208 try { 209 memboGo.Field.Autocomplete.init(); 210 } catch (e) { 211 memboGo.core.dispatchException(e); 212 } 213}
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.