1var wrapperElementId = ""; 2var isFormSubmissionSuccessful = false; 3function complete(form, success, message) { 4 EnableButton(); 5 if (success) { 6 form[0].reset(); 7 8 var targetElement = form.find(".form-wrap"); 9 10 if (targetElement.length) { 11 // Scroll to the target element 12 $('html, body').animate({ 13 scrollTop: targetElement.offset().top - 80 14 }, 'slow'); 15 } 16 17 var messageContainer = form.next('.form-sent-message'); 18 19 if (messageContainer.length) { 20 messageContainer.find('p').text(message); 21 form.toggle(500); 22 messageContainer.show(); 23 } 24 } 25 else { 26 ShowErrorMessage(message); 27 } 28} 29 30function FormFieldViewModel(label, name, type, value, ordinal) { 31 this.label = label; 32 this.name = name; 33 this.type = type; 34 this.value = value; 35 this.ordinal = 0; 36} 37 38function FormSubmitSuccess(response, status, event) { 39 var form = $('#'+wrapperElementId+' form'); 40 let message = ""; 41 if(!response.ResponseMessage){ 42 message = form.data('form-message'); 43 }else{ 44 message = response.ResponseMessage; 45 } 46 complete(form, !response.ResponseMessage, message); 47} 48 49function FormSubmitFailure(event, status, errorMessage) { 50 var form = $('#'+wrapperElementId+' form'); 51 complete(form, false, event.responseText); 52} 53 54window.MaskPhoneNumber = function(inputId) { 55 $("#"+inputId).mask("(999) 999-9999"); 56} 57 58function ResetModalForm(modalId){ 59 EnableButton(); 60 $('#' + modalId).find('form').css('display', 'block'); 61 $('#' + modalId).find('.form-sent-message.lead').css('display', 'none'); 62} 63 64function DisableButton(){ 65 $('.btn-inventory-lead-form').prop("disabled",true); 66 $('.btn-inventory-lead-form').html("Sending..."); 67} 68 69function EnableButton(){ 70 $('.btn-inventory-lead-form').prop("disabled",false); 71 $('.btn-inventory-lead-form').html("Send"); 72} 73 74window.inventoryFormInterop = { 75 submitForm: async function(elementId, razor) { 76 await submitDealerForm(elementId, function(isFormSubmissionSuccessful) { 77 razor.invokeMethodAsync('HandleSuccessfulFormSubmission', isFormSubmissionSuccessful); 78 }); 79 } 80} 81 82function submitDealerForm(elementId, callback){ 83 wrapperElementId = elementId; 84 var form = $('#'+ wrapperElementId + ' form'); 85 var $submitBtn = form.find('.btn-primary'); 86 87 if(form.valid()) 88 { 89 var currIndex = -1; 90 var formData = new FormData(); 91 var $currParent = [null]; 92 var ffvm = new FormFieldViewModel(); 93 DisableButton(); 94 // keep track if we've set the Fields[currindex].value yet since this will 95 // change if it's a dropzone file. 96 var valueAdded = false; 97 var currAnswerItemCount = 0; 98 form.find('[name^="FormField_"]:input, .dropzone').each(function (i, el) { 99 var isAnswerItem = $(el).is("input:checkbox, input:radio"); 100 if ($(el).closest(".form-component")[0] !== $currParent[0]) { 101 currIndex++; 102 currAnswerItemCount = 0; 103 valueAdded = false; 104 $currParent = $(el).closest(".form-component"); 105 106 ffvm.name = $(el).attr("name") || ""; 107 ffvm.type = $(el).data("type"); 108 109 if ($currParent.closest("[data-gjs-type]").hasClass("form-forms-agreementstatement")) { 110 isAnswerItem = false; 111 ffvm.label = $(el).closest("label").text(); 112 ffvm.value = $(el).is(":checked") ? "Checked" : "Unchecked"; 113 } else { 114 ffvm.label = $currParent.find(".control-label").text() || ""; 115 ffvm.value = !isAnswerItem ? ($(el).val() || "") : ""; 116 } 117 118 formData.append("fields[" + currIndex + "].label", ffvm.label.trim()); 119 formData.append("fields[" + currIndex + "].name", ffvm.name.trim()); 120 formData.append("fields[" + currIndex + "].type", ffvm.type); 121 } 122 123 // if the type is radio or checkbox, we want to add the value to the answer list 124 // only if the input is checked. 125 if (isAnswerItem) { 126 if ($(el).is(":checked")) { 127 var currAnswerItem = new AnswerOption(); 128 var $label = $(el).closest("label"); 129 var inputVal = $(el).val(); 130 131 currAnswerItem.value = (inputVal === "" || inputVal.toLowerCase() === "on") ? $label.text() : inputVal; 132 currAnswerItem.imagewidth = 0; 133 currAnswerItem.imagesourcedata = ""; 134 135 if ($currParent.find("div.multiplechoice-noImage ").length == 0) { 136 currAnswerItem.imagesourcedata = $label.find("img").length ? $label.find("img").attr("src") : ""; 137 currAnswerItem.imagewidth = $label.find("img").length ? Math.round($label.find("img").width()) : 0; 138 } 139 140 if (currAnswerItem.value.trim() == "Other") { 141 var textValue = $(el).closest('.form-check').find('input.form-control:text').val(); 142 currAnswerItem.value = "Other: " + textValue.trim(); 143 } 144 145 formData.append("fields[" + currIndex + "].answeroptions[" + currAnswerItemCount + "].imagesourcedata", currAnswerItem.imagesourcedata); 146 formData.append("fields[" + currIndex + "].answeroptions[" + currAnswerItemCount + "].imagewidth", currAnswerItem.imagewidth); 147 formData.append("fields[" + currIndex + "].answeroptions[" + currAnswerItemCount + "].value", currAnswerItem.value.trim()); 148 149 currAnswerItemCount++; 150 } 151 } else if (el.dropzone) { 152 var currDropzone = el.dropzone; 153 var currParmname = currDropzone.options.paramName; 154 155 if (currDropzone.files.length) {
156 currDropzone.files.forEach(function (file, i) { 157 formData.append(currParmname + '[' + i + ']', file); 158 ffvm.value = file.name; 159 }); 160 } 161 } 162 163 // Now append the .value FormData field after we know it has been set to the filename 164 // if it was a file, or left to the original value if not a file. 165 // This would be easier with "FormData.Set", but IE doesn't support FormData.set 166 if (!valueAdded) { 167 formData.append("fields[" + currIndex + "].value", ffvm.value.trim()); 168 } 169 }); 170 171 formData.append("formId", form.data('form-id')); 172 formData.append("formName", form.data('form-name')); 173 formData.append("__RequestVerificationToken", form.find('[name="__RequestVerificationToken"]').val()); 174 175 try { 176 $.ajax({ 177 url: form.attr('action'), 178 type: "POST", 179 contentType: false, 180 processData: false, 181 data: formData, 182 success: function (resp) { 183 if (callback) { 184 // Invoke the callback with the success status 185 callback(true); 186 } 187 FormSubmitSuccess.call(form[0], resp); 188 $submitBtn.html($submitBtn.data('html')); 189 }, 190 error: function (resp) { 191 if (callback) { 192 // Invoke the callback with the failure status 193 callback(false); 194 } 195 FormSubmitFailure.call(form[0], resp); 196 EnableButton(); 197 $submitBtn.html($submitBtn.data('html')); 198 } 199 }); 200 } catch (err) { 201 $submitBtn.html($submitBtn.data('html')); 202 if (callback) { 203 // Invoke the callback with the failure status 204 callback(false); 205 } 206 FormSubmitFailure.call(form[0], { responseText: err }); 207 } 208 } else { 209 // can't just put this at the bottom of the function because then it would hide 210 // it right away if the form was valid due to having to wait for an async response. 211 $submitBtn.html($submitBtn.data('html')); 212 213 var navHeight = $("nav.affix").height() + 10; 214 215 window.setTimeout(function () { 216 var errors = $('.has-error'); 217 if (errors.length) { 218 $('html, body').animate({ scrollTop: errors.offset().top - navHeight }, 500); 219 } 220 }, 0); 221 } 222} 223 224function initInventorySlideshow() { 225 226 const sharedSlickSettings = { 227 lazyLoad: 'ondemand', 228 infinite: true, 229 adaptiveHeight: true, 230 prevArrow: '<button type="button" aria-label="Previous" class="inventoryslideshow-arrow inventoryslideshow-arrow-prev btn btn-secondary"><i class="fa fa-chevron-left"></i></button>', 231 nextArrow: '<button type="button" aria-label="Next" class="inventoryslideshow-arrow inventoryslideshow-arrow-next btn btn-secondary"><i class="fa fa-chevron-right"></i></button>', 232 }; 233 234 function getSlideshowConfig(layout = 1) { 235 236 if (layout === 1 || layout === 3 || layout === 4 || layout === 5 || layout === 6 || layout === 7) { 237 return $.extend({}, sharedSlickSettings, { 238 slidesToShow: 4, 239 slidesToScroll: 4, 240 responsive: [ 241 { 242 breakpoint: 992, 243 settings: { 244 slidesToShow: 2, 245 slidesToScroll: 2 246 } 247 }, 248 { 249 breakpoint: 600, 250 settings: { 251 slidesToShow: 1, 252 slidesToScroll: 1 253 } 254 } 255 ] 256 }) 257 } 258 259 if (layout === 2) { 260 return $.extend({}, sharedSlickSettings, { 261 slidesToShow: 3, 262 slidesToScroll: 3, 263 responsive: [ 264 { 265 breakpoint: 992, 266 settings: { 267 slidesToShow: 2, 268 slidesToScroll: 2 269 } 270 }, 271 { 272 breakpoint: 600, 273 settings: { 274 slidesToShow: 1, 275 slidesToScroll: 1 276 } 277 } 278 ] 279 }) 280 } 281 282 return $.extend({}, sharedSlickSettings, { 283 slidesToShow: 1, 284 slidesToScroll: 1, 285 }); 286 } 287 288 $('.inventoryslideshow-slick').each(function(index, el) { 289 if (el.slick !== undefined) { 290 el.slick.refresh(); 291 return; 292 } 293 var $el = $(el); 294 var dataLayout = $el.data('layout'); 295 var layout = parseInt(dataLayout != null ? dataLayout : '1', 10); 296 var config = getSlideshowConfig(layout); 297 $el.slick(config); 298 }); 299}
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.