1/** 2 * @DealerVenom Modal 3 * @param {object} obj 4 * @param {int} id 5 * @param {boolean} isDisclaimer 6 * @param {string} modalType 7 * @param {object} dataObj 8 * @param {string} customClass 9 * @onclick=DVPopUp(this, id, isDisclaimer, modalType, dataObj, customClass) 10 */ 11var DVPopUp = function (obj, id, isDisclaimer, modalType, dataObj, customClass = '') { 12 var isDisclaimerVar = true; 13 if (isDisclaimer != undefined && isDisclaimer == false) { 14 isDisclaimerVar = isDisclaimer; 15 } 16 var isModalOpen = false; 17 var msg = $(obj).data("disclaimer") || $(obj).data("modal-content"); 18 19 var formId = $(obj).data("form-id"); 20 if (formId) { 21 msg = '<div class="dv-form-loading" style="text-align:center;padding:20px;"><i class="fas fa-spinner fa-spin"></i> Loading Form...</div>'; 22 // submitting the form doesn't clear this. Clear proactively so that a user can submit the same form again (presumably on a different CTA) 23 window[`gf_submitting_${formId}`] = false 24 } 25 26 var iframe_url = $(obj).data("video-url"); 27 var overrideModalTitle = $(obj).data('modal-title'); 28 var videoMatch; 29 var DVYouTubePlayer; 30 var unique = Math.floor(Math.random() * 101); 31 32 if (iframe_url != undefined) { 33 if (iframe_url.includes('/embed/')) { 34 videoMatch = iframe_url.match(/^.*embed\/(.+)$/); 35 } else if (iframe_url.includes('/watch?')) { 36 videoMatch = iframe_url.match(/^.*\?v=(.+)$/); 37 } 38 } 39 if (id) { 40 var el = $("#" + id).html(); 41 } 42 43 var buildModal = function () { 44 var hasIframe = ((msg && msg.indexOf('<iframe') !== -1) || (el && el.indexOf('<iframe') !== -1)) ? 'dv-has-iframe' : ''; 45 46 var html = 47 '<div class="dv-global-modal dv-global-modal-' + unique + ' ' + customClass + '">'; 48 html += '<div class="dv-global-modal-mask"></div>'; 49 html += '<div class="dv-global-modal-dialog ' + hasIframe + '">'; 50 html += '<span id="dv-close-modal"><i class="fal fa-times"></i></span>'; 51 html += '<div class="dv-global-modal-inner ' + hasIframe + '">'; 52 if (overrideModalTitle !== undefined || isDisclaimerVar || modalType == 'shareVDP' || modalType == 'shareSpecial') { 53 html += '<div class="dv-global-modal-header">'; 54 if (overrideModalTitle !== undefined && overrideModalTitle.length > 0) { 55 html += '<p class="dv-global-modal-header-label">' + overrideModalTitle + '</p>'; 56 } else if (isDisclaimerVar) { 57 html += '<p class="dv-global-modal-header-label">Disclaimer</p>'; 58 } 59 if (modalType == 'shareSpecial') { 60 for (var key in dataObj) { 61 if (dataObj[key] == undefined) { 62 dataObj[key] = ''; 63 } 64 } 65 html += '<div class="dv-global-modal-vehicle">'; 66 html += '<div class="dv-global-modal-vehicle-col">'; 67 html += '<h2>' + dataObj.title + '</h2>'; 68 html += '<span style="font-size: 12px;margin-top:6.25px">Only valid at ' + dataObj.dealerName + '</span>'; 69 70 if (dataObj?.hideExpiration == false) { 71 html += '<span style="font-size: 12px;margin-top:6.25px">Expires: ' + dataObj.expires + '</span>'; 72 } 73 74 html += '</div>'; 75 html += '<div class="dv-global-modal-vehicle-col">'; 76 html += '<img src="' + dataObj.image + '" class="dv-global-modal-vehicle-image" alt=""/>'; 77 html += '</div>'; 78 html += '</div>'; 79 } 80 if (modalType == 'shareVDP') { 81 for (var key in dataObj) { 82 if (dataObj[key] == undefined) { 83 dataObj[key] = ''; 84 } 85 } 86 var buildVehName = (dataObj.new_used + ' ' + dataObj.year + ' ' + dataObj.vehicle_make.name + ' ' + dataObj.model.name + ' ' + dataObj.trim.name + ' ' + dataObj.body + ' ' + dataObj.drivetrain).toUpperCase(); 87 html += '<div class="dv-global-modal-vehicle">'; 88 html += '<div class="dv-global-modal-vehicle-col">'; 89 html += '<h2>' + buildVehName + '</h2>'; 90 if (dataObj.vin) { 91 html += '<span class="dv-global-modal-vehicle-vin">VIN: ' + dataObj.vin + '</span>'; 92 } 93 if (dataObj.stock_number) { 94 html += '<span class="dv-global-modal-vehicle-stock">STOCK: ' + dataObj.stock_number + '</span>'; 95 } 96 html += '</div>'; 97 html += '<div class="dv-global-modal-vehicle-col">'; 98 if (dataObj.image_urls != undefined) { 99 vehImage = dataObj.image_urls; 100 if (vehImage != undefined) { 101 if (Array.isArray(vehImage)) { 102 vehImage = vehImage[0]; 103 } else { 104 vehImage = vehImage.split(",")[0]; 105 } 106 } 107 html += '<img src="' + vehImage + '" class="dv-global-modal-vehicle-image" alt=""/>'; 108 } 109 html += '</div>'; 110 html += '</div>'; 111 } 112 html += '</div>'; 113 } 114 html += '<div class="dv-global-modal-body ' + hasIframe + '">'; 115 if (modalType == 'shareSpecial') { 116 for (var key in dataObj) { 117 if (dataObj[key] == undefined) { 118 dataObj[key] = ''; 119 } 120 } 121 html += '<h2 class="dv-global-share-h2">SHARE SPECIAL</h2>'; 122 html += '<a data-ag-event="cta_interaction" data-offer-title="' + dataObj.title + '" href="sms:?&body=' + dataObj.dealerName + ' Coupon Special ' + dataObj.url + '" class="dv-modal-share-btn dv-modal-share-btn_sms" target="_blank"><i class="fas fa-sms"></i> SMS</a>'; 123 html += '<a data-ag-event="cta_interaction" data-offer-title="' + dataObj.title + '" href="mailto:?subject=' + dataObj.dealerName + '%20Coupon%20Special&body=' + dataObj.dealerName + ' Coupon Special ' + dataObj.url + '" class="dv-modal-share-btn dv-modal-share-btn_email" target="_blank"><i class="fas fa-envelope"></i> Email</a>'; 124 html += '<a data-ag-event="cta_interaction" data-offer-title="' + dataObj.title + '" href="javascript:void(0);" class="dv-modal-share-btn dv-modal-share-btn_copy" onclick="CopyToClipboard(this, \'' + dataObj.url + '\')"><i class="fa fa-link" aria-hidden="true"></i> <span>Copy Link to Share</span></a>'; 125 126 if (dataObj?.enablePrint == true) { 127 html += '<a data-ag-event="cta_interaction" data-offer-title="' + dataObj.title + '" href="' + dataObj.url + '" class="dv-modal-share-btn dv-modal-share-btn_print" id="share-print"><i class="fa fa-print" aria-hidden="true"></i> <span>Print</span></a>'; 128 } 129 130 html += '<textarea id="dv-modal-share-copy-link">' + dataObj.url + '</textarea>'; 131 } 132 if (msg || iframe_url || videoMatch || modalType == 'shareVDP') { 133 if (modalType == '360') { 134 html += '<div id="panorama" style="width:100%;height:0;margin:auto;padding-bottom:56.25%;"></div>'; 135 } else if (modalType == 'srp-video' || modalType == 'vdp-video') { 136 if (videoMatch != null) { 137 html += '<div id="dv-yt-player"></div>'; 138 } else { 139 html += '<div id="custom_player" style="position:relative;width:100%;height:0;margin:auto;padding-bottom:56.25%;"><iframe src="' + iframe_url + '" scrolling="yes" frameborder="0" style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>' 140 } 141 } else if (modalType == 'shareVDP') { 142 html += '<h2 class="dv-global-share-h2">SHARE VEHICLE</h2>'; 143 html += '<a href="https://www.facebook.com/sharer/sharer.php?u=' + window.location.href + '" class="dv-modal-share-btn dv-modal-share-btn_facebook" target="_blank"><i class="fab fa-facebook-f"></i> Facebook</a>'; 144 html += '<a href="https://twitter.com/intent/tweet?text=' + window.location.href + '" class="dv-modal-share-btn dv-modal-share-btn_twitter" target="_blank"><i class="fa-brands fa-x-twitter"></i> X</a>'; 145 html += '<a href="javascript:void(0);" class="dv-modal-share-btn dv-modal-share-btn_copy" onclick="CopyToClipboard(this, window.location.href)"><i class="fa fa-link" aria-hidden="true"></i> <span>Copy Link to Share</span></a>'; 146 html += '<textarea id="dv-modal-share-copy-link">' + window.location.href + '</textarea>'; 147 148 } else { 149 html += '<div class="dv-global-modal-text ' + hasIframe + '">'; 150 html += msg; 151 html += "</div>"; 152 } 153 } else { 154 if (el != undefined) { 155 html += '<div class="dv-global-modal-text ' + hasIframe + '">' + el + "</div>"; 156 } 157 } 158 html += "</div>"; 159 html += "</div>"; 160 html += "</div>"; 161 html += "</div>"; 162 $(html).appendTo("body"); 163 $("body").addClass("dv-global-modal-open"); 164 165 if (formId) { 166 let ajaxData = { 167 action: 'get_gform', 168 form_id: formId, 169 referrer_url: window.location.href 170 }; 171 172 let combinedData = DVHydrate.collectData(obj); 173 ajaxData['vin'] = combinedData.vin; 174 175 $.ajax({ 176 url: '/wp/wp-admin/admin-ajax.php', 177 type: 'POST', 178 data: ajaxData, 179 success: function (response) { 180 if (response.success) { 181 $('.dv-global-modal-' + unique + ' .dv-global-modal-text').html(response.data.html); 182 if (typeof wpae_reinitalize_after_form_load === 'function') { 183 wpae_reinitalize_after_form_load(); 184 } else if (typeof wpa_add_honeypot_field === 'function') { 185 wpa_add_honeypot_field(); 186 } 187 $(document).trigger('gform_post_render', [formId, 1]); 188 } else { 189 $('.dv-global-modal-' + unique + ' .dv-global-modal-text').html('<p>Error loading form.</p>'); 190 } 191 }, 192 error: function () { 193 $('.dv-global-modal-' + unique + ' .dv-global-modal-text').html('<p>Error loading form.</p>'); 194 } 195 }); 196 } 197 198 // has to be here so once it renders on the body, it can init the yt api 199 if (videoMatch != null) { 200 var videoId = videoMatch[1]; 201 var height = document.documentElement.clientHeight; 202 var width = document.documentElement.clientWidth; 203 204 if (typeof this.mobilecheck === 'function' && this.mobilecheck()) { 205 width = "100%"; 206 height = "250px"; 207 } else { 208 width = "100%"; 209 height = "600px"; 210 } 211 DVYouTubePlayer = new YT.Player('dv-yt-player', { 212 width: '100%', 213 height: height, 214 videoId: videoId, 215 playerVars: { autoplay: 1 }, 216 events: { 217 // call this function when player is ready to use 218 // 'onReady': onPlayerReady, 219 'onStateChange': onPlayerChange 220 } 221 }); 222 223 var done = false;
224 function onPlayerChange(event) { 225 if (event.data == YT.PlayerState.PLAYING && !done) { 226 //setTimeout(stopVideo, 6000); 227 //done = true; 228 } 229 } 230 function stopVideo() { 231 DVYouTubePlayer.stopVideo(); 232 } 233 } 234 // has to be here so once it renders on the body, it can init the panoroma 235 if (modalType == '360') { 236 pannellum.viewer('panorama', { 237 "type": "equirectangular", 238 "panorama": msg, 239 "autoLoad": true, 240 "hfov": 120, 241 }); 242 } 243 }; 244 245 if (isModalOpen === false) { 246 isModalOpen = true; 247 buildModal(); 248 } 249 250 var CloseModal = function () { 251 $(".dv-global-modal").fadeOut("fast", function () { 252 $("body").removeClass("dv-global-modal-open"); 253 $(this).remove(); 254 isModalOpen = false; 255 }); 256 }; 257 $("body").on("click", "#dv-close-modal", function () { 258 CloseModal(); 259 }); 260 $(".dv-global-modal").click(function (event) { 261 if (isModalOpen) { 262 setTimeout(function () { 263 if ( 264 !$(event.target).closest(".dv-global-modal-dialog") 265 .length && 266 !$(event.target).is(".dv-global-modal-dialog") 267 ) { 268 CloseModal(); 269 } 270 }, 100); 271 } 272 }); 273 274 return false; 275}; 276 277var DVPopUpContent = function (obj) { 278 var isModalOpen = false; 279 var msg = $(obj)[0].attributes['data-modal-content'].value; 280 var unique = Math.floor(Math.random() * 101); 281 282 var buildModal = function () { 283 var hasIframe = (msg && msg.indexOf('<iframe') !== -1) ? 'dv-has-iframe' : ''; 284 285 var html = 286 '<div class="dv-global-modal dv-global-modal-' + unique + '">'; 287 html += '<div class="dv-global-modal-mask"></div>'; 288 html += '<div class="dv-global-modal-dialog ' + hasIframe + '">'; 289 html += '<span id="dv-close-modal"><i class="fal fa-times"></i></span>'; 290 html += '<div class="dv-global-modal-inner ' + hasIframe + '">'; 291 292 html += '<div class="dv-global-modal-body ' + hasIframe + '">'; 293 if (msg) { 294 html += '<div class="dv-global-modal-text ' + hasIframe + '">'; 295 html += msg; 296 html += "</div>"; 297 } 298 html += "</div>"; 299 html += "</div>"; 300 html += "</div>"; 301 html += "</div>"; 302 $(html).appendTo("body"); 303 $("body").addClass("dv-global-modal-open"); 304 }; 305 306 if (isModalOpen === false) { 307 isModalOpen = true; 308 buildModal(); 309 } 310 311 var CloseModal = function () { 312 $(".dv-global-modal").fadeOut("fast", function () { 313 $("body").removeClass("dv-global-modal-open"); 314 $(this).remove(); 315 isModalOpen = false; 316 }); 317 }; 318 $("body").on("click", "#dv-close-modal", function () { 319 CloseModal(); 320 }); 321 $(".dv-global-modal").click(function (event) { 322 if (isModalOpen) { 323 setTimeout(function () { 324 if ( 325 !$(event.target).closest(".dv-global-modal-dialog") 326 .length && 327 !$(event.target).is(".dv-global-modal-dialog") 328 ) { 329 CloseModal(); 330 } 331 }, 100); 332 } 333 }); 334 335 return false; 336}; 337 338var CopyToClipboard = function CopyToClipboard(copyEL, toCopy) { 339 var el = document.createElement("textarea"); 340 el.value = toCopy; 341 el.setAttribute("readonly", ""); 342 el.style.position = "absolute"; 343 el.style.left = "-9999px"; 344 document.body.appendChild(el); 345 el.select(); 346 document.execCommand("copy"); 347 document.body.removeChild(el); 348 copyEL.children[1].innerHTML = 'Copied!'; 349}; 350 351// var CopyLinkText = function(el, containerid) { 352// var isCopied = false; 353// if (window.getSelection) { 354// if (window.getSelection().empty) { // Chrome 355// window.getSelection().empty(); 356// } else if (window.getSelection().removeAllRanges) { // Firefox 357// window.getSelection().removeAllRanges(); 358// } 359// } else if (document.selection) { // IE? 360// document.selection.empty(); 361// } 362 363// if (document.selection) { 364// var range = document.body.createTextRange(); 365// range.moveToElementText(document.getElementById(containerid)); 366// range.select().createTextRange(); 367// document.execCommand("copy"); 368// isCopied = true; 369// } else if (window.getSelection) { 370// var range = document.createRange(); 371// range.selectNode(document.getElementById(containerid)); 372// window.getSelection().addRange(range); 373// document.execCommand("copy"); 374// isCopied = true; 375// } 376 377// if(isCopied){ 378// el.children[1].innerHTML = 'Copied!'; 379// } 380// }; 381 382/** 383 * 384 * @onclick=DVPopUpModalNew(this) 385 */ 386var DVContentPopUpNew = function(obj,id,isDisclaimer,modalType) { 387 var isDisclaimerVar = true; 388 if(isDisclaimer != undefined && isDisclaimer == false){ 389 isDisclaimerVar = isDisclaimer; 390 } 391 var isModalOpen = false;
392 var msg = $(obj).data("disclaimer"); 393 var jobTitle = $(obj).data("jobtitle"); 394 var fullName = $(obj).data("fullname"); 395 var empImage = $(obj).data("empimg"); 396 var iframe_url = $(obj).data("video-url"); 397 var videoMatch; 398 var DVYouTubePlayer; 399 var unique = Math.floor(Math.random() * 101); 400 401 if(iframe_url != undefined) { 402 if (iframe_url.includes('/embed/')) { 403 videoMatch = iframe_url.match(/^.*embed\/(.+)$/); 404 } else if (iframe_url.includes('/watch?')) { 405 videoMatch = iframe_url.match(/^.*\?v=(.+)$/); 406 } 407 } 408 if (id) { 409 var el = $("#" + id).html(); 410 } 411 if(msg){ 412 var cls='dv-custom-modal'; 413 }else{ 414 var cls='dv-custom-vid-modal'; 415 } 416 417 var buildModalPopUp = function(){ 418 var hasIframe = ((msg && msg.indexOf('<iframe') !== -1) || (el && el.indexOf('<iframe') !== -1)) ? 'dv-has-iframe' : ''; 419 420 var html = '<div class="dv-global-modal '+cls+' dv-global-modal-'+unique+'">'; 421 html += '<div class="dv-global-modal-mask"></div>'; 422 html += '<div class="dv-global-modal-dialog ' + hasIframe + '">'; 423 html += '<span id="dv-close-modal"><i class="fal fa-times"></i></span>'; 424 html += '<div class="dv-global-modal-inner ' + hasIframe + '"><div class="dv-global-modal-body ' + hasIframe + '">'; 425 if (msg || iframe_url || videoMatch) { 426 if(modalType == 'srp-video' || modalType == 'vdp-video'){ 427 if(videoMatch != null){ 428 html += '<div id="dv-yt-player"></div>'; 429 } else { 430 html += '<div id="custom_player" style="position:relative;width:100%;height:0;margin:auto;padding-bottom:56.25%;"><iframe src="' + iframe_url + '" scrolling="yes" frameborder="0" style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>' 431 } 432 }else{ 433 html += '<div class="dv-global-modal-text ' + hasIframe + '">'; 434 html += '<div class="dv-team-bio-section"><div class="short-info-box">'; 435 html += '<div class="dv-member-image"><img class="dv-team-member-image-style-4 no-hover" src='+empImage+'&w=250 alt="'+fullName+' Photo"></div>'; 436 html += '<div class="dv-member-content"><h3>'+fullName+'</h3><h4>'+jobTitle+'</h4>'; 437 html += '<div class="bio">'+msg+'</div></div>'; 438 html += '</div></div></div>'; 439 } 440 } 441 html +='</div></div>'; 442 html += '</div>'; 443 html += '</div>'; 444 $(html).appendTo('body'); 445 $('body').addClass('dv-global-modal-open'); 446 447 if(videoMatch != null){ 448 var videoId = videoMatch[1]; 449 var height = document.documentElement.clientHeight; 450 var width = document.documentElement.clientWidth; 451 452 DVYouTubePlayer = new YT.Player('dv-yt-player', { 453 width: '100%', 454 height: '100%', 455 videoId: videoId, 456 playerVars: { autoplay: 1 }, 457 events: { 458 // call this function when player is ready to use 459 // 'onReady': onPlayerReady, 460 'onStateChange': onPlayerChange 461 } 462 }); 463 464 var done = false; 465 function onPlayerChange(event) { 466 if (event.data == YT.PlayerState.PLAYING && !done) { 467 //setTimeout(stopVideo, 6000); 468 //done = true; 469 } 470 } 471 function stopVideo() { 472 DVYouTubePlayer.stopVideo(); 473 } 474 } 475 } 476 477 if (isModalOpen === false) { 478 isModalOpen = true 479 buildModalPopUp(); 480 } 481 482 var CloseModalPopUp = function() { 483 $('.dv-global-modal').fadeOut("fast", function(){ 484 $('body').removeClass('dv-global-modal-open') 485 $(this).remove(); 486 isModalOpen = false; 487 },) 488 }; 489 $('body').on("click", "#dv-close-modal", function() { 490 CloseModalPopUp(); 491 }); 492 $('.dv-global-modal').click(function (event){ 493 if (isModalOpen) { 494 setTimeout(function(){ 495 if(!$(event.target).closest('.dv-global-modal-dialog').length && !$(event.target).is('.dv-global-modal-dialog')) { 496 CloseModalPopUp(); 497 } 498 }, 100) 499 } 500 }); 501}; 502 503/** 504 * Handle AJAX Form Submission for Modals 505 */ 506$(document).on('submit', '.dv-global-modal .dv-global-modal-text form', function (e) { 507 let $form = $(this); 508 // Only intercept if the action points to our AJAX handler 509 if ($form.attr('action').indexOf('action=get_gform') !== -1) { 510 e.preventDefault(); 511 let $container = $form.closest('.dv-global-modal-text'); 512 let action = $form.attr('action'); 513 let formData = new FormData(this); 514 515 $container.css('opacity', '0.5'); 516 517 $.ajax({ 518 url: action, 519 type: 'POST', 520 data: formData, 521 processData: false, 522 contentType: false, 523 success: function (response) { 524 $container.css('opacity', '1'); 525 526 const doc = new DOMParser().parseFromString(response, 'text/html'); 527 const inner = doc.querySelector('div.main.container')?.innerHTML ?? ''; 528 529 $container.html(inner); 530 531 // Re-initialize WP Armour 532 if (typeof wpae_reinitalize_after_form_load === 'function') { 533 wpae_reinitalize_after_form_load(); 534 } else if (typeof wpa_add_honeypot_field === 'function') { 535 wpa_add_honeypot_field(); 536 } 537 538 // Trigger Gravity Forms post render for validation errors or confirmation 539 let formIdMatch = response.match(/id=['"]gform(?:_confirmation)?_wrapper_(\d+)['"]/); 540 if (formIdMatch) { 541 $(document).trigger('gform_post_render', [formIdMatch[1], 1]); 542 } 543 }, 544 error: function () { 545 $container.css('opacity', '1'); 546 $container.html('<p>Error submitting form. Please try again.</p>'); 547 } 548 }); 549 } 550});
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.