1function YpmPopup() { 2 3 this.ypmCount = 0; 4 this.popupData = []; 5 this.popupId = 0; 6} 7 8YpmPopup.prototype.setPopupData = function(popupData) { 9 10 popupData = this.filterPopupData(popupData); 11 this.popupData = popupData; 12}; 13 14YpmPopup.prototype.getPopupData = function() { 15 16 return this.popupData; 17}; 18 19YpmPopup.prototype.setPopupId = function(popupId) { 20 21 this.popupId = popupId; 22}; 23 24YpmPopup.prototype.getPopupId = function() { 25 26 return this.popupId; 27}; 28 29YpmPopup.prototype.varToBool = function (optionName) { 30 31 var returnValue = (optionName) ? true : false; 32 return returnValue; 33}; 34 35YpmPopup.prototype.init = function () { 36 37 var that = this; 38 jQuery(".ypm-open-popup").each(function () { 39 var currentPopup = jQuery(this); 40 var popupEvent = jQuery(this).attr("data-popup-event"); 41 if (typeof popupEvent == 'undefined') { 42 popupEvent = 'click'; 43 } 44 45 that.ypmCount = 0; 46 var callBack = function () { 47 48 that.ypmCount += 1; 49 var status = that.ypmCount > 1; 50 if (status) { 51 return; 52 } 53 var popupId = currentPopup.attr("data-ypm-popup-id"); 54 var data = YPM_DATA[popupId]; 55 if(typeof data == 'undefined') { 56 return false; 57 } 58 that.setPopupId(popupId); 59 that.setPopupData(data); 60 that.openPopup(); 61 }; 62 63 if (popupEvent == 'click') { 64 jQuery(this).bind(popupEvent, function () { 65 callBack(); 66 }); 67 } 68 else if (popupEvent == 'hover') { 69 jQuery(this).hover(function () { 70 callBack(); 71 }, function () { 72 73 }); 74 } 75 }); 76}; 77 78YpmPopup.prototype.fomSubmition = function () { 79 var that = this; 80 81 document.addEventListener( 'wpcf7submit', function( event ) { 82 83 var data = that.getPopupData(); 84 if (data['ypm-popup-special-events-settings'] && event.detail.status == 'mail_sent') { 85 var specialEvents = data['ypm-popup-special-events-settings']; 86 for (var i in specialEvents) { 87 var current = specialEvents[i]; 88 if (current['key1'] === 'Cf7') { 89 switch (current['key2']) { 90 case "redirectToUrl": 91 window.location.href = current['key3']; 92 break; 93 case "openAnotherPopup": 94 YpmObserver.openPopupById(current['key3']); 95 break; 96 case "closePopup": 97 setTimeout(function () { 98 YpmPopup.closePopup(); 99 }, parseInt(current['key3'])*1000) 100 } 101 } 102 } 103 } 104 105 106 }, false ); 107 108 jQuery(document).on('wpformsAjaxSubmitSuccess', '.wpforms-ajax-form', function (event, details) { 109 var data = that.getPopupData(); 110 var specialEvents = data['ypm-popup-special-events-settings']; 111 if (data['ypm-popup-special-events-settings']) { 112 for (var i in specialEvents) { 113 var current = specialEvents[i]; 114 if (current['key1'] === 'wpform') { 115 switch (current['key2']) { 116 case "wpformRedirectToUrl": 117 window.location.href = current['key3']; 118 break; 119 case "wpformOpenAnotherPopup": 120 YpmObserver.openPopupById(current['key3']); 121 break; 122 case "wpformClosePopup": 123 setTimeout(function () { 124 YpmPopup.closePopup(); 125 }, parseInt(current['key3'])*1000) 126 } 127 } 128 } 129 } 130 }) 131} 132 133YpmPopup.prototype.customEvents = function() { 134 135 var data = this.getPopupData(); 136 137 jQuery('#ypmcolorbox').on('ypmOnOpen', function() { 138 139 }); 140}; 141 142YpmPopup.prototype.openByPopupEvent = function() { 143 144 var popupId = this.getPopupId(); 145 146 if(typeof YPM_DATA[popupId] == 'undefined') { 147 return; 148 } 149 var data = YPM_DATA[popupId]; 150 this.setPopupData(data); 151 152 if(typeof data['ypm-popup-exit-enable'] != 'undefined' && data['ypm-popup-exit-enable'] == 'on') { 153 YpmPopup.prototype = new YpmExit(); 154 } 155 else { 156 this.onLoad(); 157 } 158}; 159 160YpmPopup.prototype.openPopup = function (popupId) { 161 162 this.setPopupId(popupId); 163 164 this.openByPopupEvent(); 165}; 166 167YpmPopup.prototype.onLoad = function() { 168 169 var data = this.getPopupData(); 170 var that = this; 171 172 var isAllowToLoad = that.allowToLoad(); 173 if (!isAllowToLoad) return isAllowToLoad; 174 175 setTimeout(function () { 176 that.openPopup(); 177 178 }, data['ypm-delay']*1000); 179}; 180 181YpmPopup.prototype.allowToLoad = function() { 182 var popupHasLimit = this.isSatisfyForShowingLimitation(); 183 if (popupHasLimit === false) { 184 return popupHasLimit; 185 } 186 var extensionsStatus = true; 187 var data = this.getPopupData(); 188
189 if (data['extensionsClasses']) { 190 for (var extensionIndex in data['extensionsClasses']) { 191 var extension = data['extensionsClasses'][extensionIndex]; 192 var className = extension['name']; 193 if (typeof className != undefined) { 194 className = eval(className); 195 var currentObj = new className(); 196 var currentStatus = currentObj[extension['method']](this); 197 198 if (currentStatus === false) { 199 extensionsStatus = false; 200 break; 201 } 202 } 203 } 204 205 if (!extensionsStatus) { 206 return false; 207 } 208 } 209 210 var popupType = data['ypm-popup-type']; 211 try { 212 if (extensionsStatus) { 213 var className = eval(popupType); 214 var status = className.allowToLoad(this); 215 216 if (status === false) { 217 return false; 218 } 219 } 220 } 221 catch (e) { 222 223 } 224 return true; 225}; 226 227YpmPopup.prototype.isSatisfyForShowingLimitation = function() 228{ 229 var data = this.getPopupData(); 230 var popupLimitation = data['ypm-popup-showing-limitation']; 231 232 if (!popupLimitation) { 233 return null; 234 } 235 236 var cookieData = this.getPopupShowLimitationCookie(); 237 238 /*when there is not*/ 239 if (!cookieData.cookie) { 240 return true; 241 } 242 var limitationCount = parseInt(data['ypm-limitation-shwoing-count']); 243 244 return cookieData.cookie.openingCount < limitationCount; 245}; 246 247YpmPopup.prototype.getPopupShowLimitationCookie = function() 248{ 249 var savedCookie = this.getPopupShowLimitationCookieDetails(); 250 savedCookie = this.filterPopupLimitationCookie(savedCookie); 251 252 return savedCookie; 253}; 254 255YpmPopup.prototype.filterPopupLimitationCookie = function(cookie) 256{ 257 var result = {}; 258 result.cookie = ''; 259 if (cookie.isPageLevel) { 260 261 result.cookieName = cookie.pageLevelCookieName; 262 if (cookie.pageLevelCookie) { 263 result.cookie = jQuery.parseJSON(cookie.pageLevelCookie); 264 } 265 266 YpmPopup.deleteCookie(cookie.domainLevelCookieName); 267 268 return result; 269 } 270 result.cookieName = cookie.domainLevelCookieName; 271 if (cookie.domainLevelCookie) { 272 result.cookie = jQuery.parseJSON(cookie.domainLevelCookie); 273 } 274 var currentUrl = window.location.href; 275 276 YpmPopup.deleteCookie(cookie.pageLevelCookieName, currentUrl); 277 278 return result; 279}; 280 281YpmPopup.prototype.getPopupShowLimitationCookieDetails = function() 282{ 283 var result = false;
284 var data = this.getPopupData(); 285 var currentUrl = window.location.href; 286 var currentPopupId = this.getPopupId(); 287 288 /*Cookie names*/ 289 var popupLimitationCookieHomePageLevelName = 'YPMShowingLimitationHomePage' + currentPopupId; 290 var popupLimitationCookiePageLevelName = 'YPMShowingLimitationPage' + currentPopupId; 291 var popupLimitationCookieDomainName = 'YPMShowingLimitationDomain' + currentPopupId; 292 293 var pageLevelCookie = data['ypm-show-popup-same-user-page-level'] || false; 294 295 /*check if current url is home page*/ 296 if (currentUrl === YpmParams.homePageUrl) { 297 popupLimitationCookiePageLevelName = popupLimitationCookieHomePageLevelName; 298 } 299 var popupLimitationPageLevelCookie = YpmPopup.getCookie(popupLimitationCookiePageLevelName); 300 var popupLimitationDomainCookie = YpmPopup.getCookie(popupLimitationCookieDomainName); 301 302 result = { 303 'pageLevelCookieName': popupLimitationCookiePageLevelName, 304 'domainLevelCookieName': popupLimitationCookieDomainName, 305 'pageLevelCookie': popupLimitationPageLevelCookie, 306 'domainLevelCookie': popupLimitationDomainCookie, 307 'isPageLevel': pageLevelCookie 308 }; 309 310 return result; 311}; 312 313YpmPopup.closePopup = function () { 314 jQuery.ypmcolorbox.close(); 315} 316 317YpmPopup.prototype.openPopup = function () { 318 319 this.popupEvents(); 320 this.fomSubmition(); 321 var popupId = this.getPopupId(); 322 var data = this.getPopupData(); 323 324 var href = '#ypm-popup-content-wrapper-'+popupId; 325 var photo = false; 326 var inline = true; 327 if (data['ypm-popup-type'] === 'ypmimage') { 328 href = data['ypm-image-popup-url']; 329 inline = false; 330 photo = true; 331 } 332 333 var that = this; 334 335 var title = data['title']; 336 var showTitle = this.varToBool(data['ypm-popup-title']); 337 if(!showTitle) { 338 title = false; 339 } 340 var width = data['ypm-popup-width']; 341 var height = data['ypm-popup-height']; 342 var maxWidth = data['ypm-popup-max-width'] || '100%'; 343 var maxHeight = data['ypm-popup-max-height'] || '100%'; 344 var theme = data['ypm-popup-theme']; 345 var ypmOverlayOpacity = data['ypm-overlay-opacity']; 346 var escKey = this.varToBool(data['ypm-esc-key']); 347 var closeButton = this.varToBool(data['ypm-close-button']); 348 var overlayClick = this.varToBool(data['ypm-overlay-click']); 349 var closeText = data['ypm-popup-theme-close-text']; 350 var content = data['content']; 351 var initialWidth = 300; 352 var initialHeight = 100; 353 var positionsObj = this.getPositionData(data); 354 355 var ypmConfig = { 356 popupId: popupId, 357 closeDelay: data['ypm-close-delay'], 358 title: title, 359 html: false, 360 inline: inline, 361 href: href, 362 photo: photo, 363 closeButton: closeButton, 364 overlayClose: overlayClick, 365 opacity: ypmOverlayOpacity, 366 className: 'ypm'+theme, 367 escKey: escKey, 368 fixed: positionsObj.fixed, 369 top: positionsObj.top, 370 bottom: positionsObj.bottom, 371 left: positionsObj.left, 372 right: positionsObj.right, 373 close: closeText, 374 overlayId: '#ypmcboxOverlay', 375 disableOverlay: this.varToBool(data['ypm-disable-overlay']), 376 popupOptions: data, 377 onOpen: function() { 378 jQuery(ypmConfig.overlayId).addClass("ypmcboxOverlayBg"); 379 jQuery(ypmConfig.overlayId).addClass(data['ypm-overlay-custom-class']); 380 jQuery('#ypmcolorbox').addClass(data['ypm-content-custom-class']); 381 382 if(data['ypm-overlay-color']) { 383 jQuery('.ypmcboxOverlayBg').css({ 384 'background': 'none', 385 'background-color': 386 data['ypm-overlay-color'] 387 }) 388 } 389 390 if (data['ypm-enable-bg-image']) { 391 jQuery("#ypmcboxContent").css({ 392 'background-image': 'url(' + data['ypm-background-image'] + ')', 393 'background-size': data['ypm-background-image-mode'], 394 'background-repeat': 'no-repeat', 395 'background-attachment': 'fixed', 396 'background-position': 'center' 397 }) 398 } 399 400 jQuery('#ypm-popup-content-wrapper-'+popupId).css({padding: data['ypm-content-padding']}) 401 jQuery('.ypm-popup-content-'+popupId+' #ypmcboxContent, .ypm-popup-content-'+popupId+' #ypmcboxLoadedContent').css({'border-radius': data['ypm-content-border-radius']}) 402 if(data['ypm-content-click-status']) { 403 var clickCount = 0; 404 jQuery('#ypmcboxContent').bind('click', function () { 405 clickCount += 1; 406 if (clickCount == data['ypm-content-click-count']) { 407 jQuery.ypmcolorbox.close(); 408 if (data['ypm-content-click-redirect-enable']) { 409 var url = data['ypm-content-click-redirect-url']; 410 if (data['ypm-content-click-redirect-tab']) { 411 window.open(url); 412 } 413 else { 414 window.location.href = url; 415 } 416 } 417 } 418 }); 419 } 420 var popupEffectDuration = data['ypm-popup-opening-animation-speed']; 421 jQuery('.ypm-popup-content-'+popupId).addClass('ypm-animated '+data['ypm-popup-opening-animation']) 422 jQuery('.ypm-popup-content-'+popupId).css('animation-duration', popupEffectDuration + "s"); 423 jQuery('.ypm-popup-content-'+popupId).css('-webkit-animation-duration', popupEffectDuration + "s"); 424 jQuery(ypmConfig.overlayId).css('zIndex', data['ypm-z-index']);
425 jQuery('#ypmcolorbox').trigger('ypmOnOpen', {popupId: popupId, data: data}); 426 }, 427 onCleanup: function () { 428 that.ypmCount = 0; 429 jQuery('#ypmcolorbox').trigger("ypmPopupCleanup", {popupId: popupId, data: data}); 430 }, 431 onComplete: function () { 432 jQuery("#ypmcboxClose").bind('click', function() { 433 434 if (data['ypm-close-button-click-sound']) { 435 const audio = new Audio(YpmParams.soundsURL+"/click.mp3"); 436 audio.play(); 437 } 438 }); 439 if (data['ypm-enable-close-delay'] && data['ypm-close-button']) { 440 var time = data['ypm-close-button-delay']; 441 if (data['ypm-show-close-delay']) { 442 var styles = window.getComputedStyle(document.getElementById("ypmcboxClose")); 443 444 jQuery("#ypmcboxClose").after("<span id='ypm-close-text'>"+time+"</span>"); 445 jQuery("#ypm-close-text").css({ 446 position: styles.position, 447 top: styles.top, 448 left: styles.left, 449 right: styles.right, 450 bottom: styles.bottom, 451 color: data['ypm-close-delay-color'], 452 fontSize: data['ypm-close-delay-font-size'], 453 }) 454 } 455 456 var intervalId = setInterval(function () { 457 time -= 1; 458 jQuery("#ypm-close-text").text(time); 459 if (time <= 0) { 460 clearInterval(intervalId); 461 jQuery("#ypm-close-text").remove(); 462 jQuery("#ypmcboxClose").removeClass('ypm-hide'); 463 } 464 }, 1000); 465 } 466 jQuery('.ypm-popup-content-'+popupId).removeClass('ypm-animated '+data['ypm-popup-opening-animation']) 467 jQuery('.ypm-popup-content-'+popupId+' #ypmcboxContent, .ypm-popup-content-'+popupId+' #ypmcboxLoadedContent').css({'border-radius': data['ypm-content-border-radius']}) 468 jQuery(window).trigger('ypmOnComplete', {popupId: popupId, data: data}); 469 jQuery('#ypmcolorbox').trigger('ypmOnComplete', {popupId: popupId, data: data}); 470 }, 471 onClosed: function () { 472 jQuery('#ypmcolorbox').trigger("ypmPopupClose", {popupId: popupId, data: data}); 473 switch (data['ypm-popup-close-behavior']) { 474 case 'redirect': { 475 var URL = data['ypm-popup-close-redirection-url']; 476 if (data['ypm-popup-close-redirection-url-tab']) { 477 window.open(URL) 478 } 479 else { 480 window.location.href = URL; 481 } 482 break; 483 } 484 case 'openPopup': 485 YpmPopup.openPopupById(data['ypm-popup-close-popup']); 486 break; 487 } 488 }, 489 onClosing: function () { 490 var popupCloseEffectDuration = data['ypm-popup-close-animation-speed']; 491 jQuery('.ypm-popup-content-'+popupId).addClass('ypm-animated '+data['ypm-popup-close-animation']) 492 jQuery('.ypm-popup-content-'+popupId).css('animation-duration', popupCloseEffectDuration + "s"); 493 jQuery('.ypm-popup-content-'+popupId).css('-webkit-animation-duration', popupCloseEffectDuration + "s"); 494 } 495 }; 496 497 if(width) { 498 ypmConfig.width = width; 499 } 500 if(height) { 501 ypmConfig.height = height; 502 } 503 if(maxWidth) { 504 ypmConfig.maxWidth = maxWidth; 505 } 506 if(maxHeight) { 507 ypmConfig.maxHeight = maxHeight; 508 } 509 if(initialWidth) { 510 ypmConfig.initialWidth = initialWidth; 511 } 512 if(initialHeight) { 513 ypmConfig.initialHeight = initialHeight; 514 } 515 516 if (data['ypm-popup-type'] === 'ypmlink') { 517 this.dynamicLink(ypmConfig); 518 } 519 else { 520 jQuery.ypmcolorbox(ypmConfig); 521 } 522 523 this.customEvents(); 524}; 525 526YpmPopup.prototype.popupEvents = function () 527{ 528 var that = this; 529 var colorBox = jQuery('#ypmcolorbox');
530 colorBox.bind('ypmOnOpen', function (e, args) { 531 532 }); 533 534 colorBox.bind("ypmPopupCleanup", function (e, args) { 535 536 }); 537 538 colorBox.bind("ypmOnComplete", function (e, args) { 539 540 var data = args.data; 541 var popupId = args.popupId; 542 var titleColor = data['ypm-title-color']; 543 var titleFontSize = data['ypm-popup-title-font-size']; 544 var disablePageScrolling = data['ypm-disable-page-scrolling']; 545 546 if(disablePageScrolling) { 547 jQuery('body').addClass('ypm-disable-page-scrolling'); 548 } 549 jQuery('.ypm-popup-content-'+popupId+' #ypmcboxTitle').css({color: titleColor}); 550 if (titleFontSize) { 551 jQuery('.ypm-popup-content-'+popupId+' #ypmcboxTitle').css({fontSize: titleFontSize}); 552 } 553 554 /*Popup open count*/ 555 that.openCount(args); 556 that.setPopupLimitation(args); 557 }); 558 559 colorBox.bind("ypmPopupClose", function (e, args) { 560 561 var data = args.data; 562 var disablePageScrolling = data['ypm-disable-page-scrolling']; 563 564 if(disablePageScrolling) { 565 jQuery('body').removeClass('ypm-disable-page-scrolling'); 566 } 567 }); 568}; 569 570YpmPopup.prototype.openCount = function (args) 571{ 572 if (args.data['ypm-popup-disable-statistic']) { 573 return; 574 } 575 var popupId = args.popupId; 576 var data = { 577 action: 'ypm_increment_popup_count', 578 ajaxNonce: YpmParams.ajaxNonce, 579 popupId: popupId 580 }; 581 jQuery.post(YpmParams.ajaxurl, data, function(response) { 582 }); 583}; 584 585YpmPopup.prototype.setPopupLimitation = function (args) 586{ 587 var data = this.getPopupData(); 588 var cookieData = this.getPopupShowLimitationCookie(); 589 var cookie = cookieData.cookie || {}; 590 var openingCount = cookie.openingCount || 0; 591 var currentUrl = window.location.href; 592 593 if (!data['ypm-limitation-shwoing-expiration']) { 594 currentUrl = ''; 595 } 596 cookie.openingCount = openingCount + 1; 597 cookie.openingPage = currentUrl; 598 var popupShowingLimitExpiry = parseInt(data['ypm-limitation-shwoing-expiration']); 599 600 YpmPopup.setCookie(cookieData.cookieName, JSON.stringify(cookie), popupShowingLimitExpiry, currentUrl); 601}; 602 603YpmPopup.prototype.filterPopupData = function (popupData) 604{ 605 if (popupData['ypm-popup-dimensions-mode'] == 'auto') { 606 var width = ''; 607 if (popupData['ypm-popup-dimensions-auto-size'] != 'auto') { 608 width = popupData['ypm-popup-dimensions-auto-size']+'%'; 609 } 610 popupData['ypm-popup-width'] = width; 611 popupData['ypm-popup-height'] = ''; 612 } 613 return popupData; 614}; 615 616YpmPopup.prototype.getPositionData = function (popupData) { 617 var positions = { 618 fixed: false, 619 top: false, 620 right: false, 621 bottom: false, 622 left: false, 623 }; 624 625 if (!popupData['ypm-popup-location']) { 626 return positions; 627 } 628 var position = popupData['ypm-popup-fixed-position']; 629 630 /*The center Position*/ 631 positions.fixed = true; 632 switch (position) { 633 case "1": 634 positions.left = "0px"; 635 positions.top = "0px"; 636 break; 637 case "2": 638 positions.top = "0px"; 639 break; 640 case "3": 641 positions.top = "0px"; 642 positions.right = "0px"; 643 break; 644 case "4": 645 positions.left = "0px"; 646 break; 647 case "6": 648 positions.right = "0px"; 649 break; 650 case "7": 651 positions.bottom = "0px"; 652 positions.left = "0px"; 653 break; 654 case "8": 655 positions.bottom = "0px"; 656 break; 657 case "9": 658 positions.bottom = "0px"; 659 positions.right = "0px"; 660 break; 661 } 662 663 return positions; 664}; 665 666YpmPopup.prototype.Onload = function (eventData) { 667 var that = this; 668 setTimeout(function () { 669 that.onLoad(); 670 }, parseInt(eventData['key2'])*1000) 671}; 672 673YpmPopup.prototype.OnClick = function (eventData) { 674 var that = this; 675 jQuery('.'+eventData['key3']).bind('click', function () { 676 that.onLoad(); 677 }); 678} 679 680/* Cookie helper start */ 681 682YpmPopup.getCookie = function (cName) { 683 684 var name = cName + "="; 685 var ca = document.cookie.split(';'); 686 for (var i = 0; i < ca.length; i++) { 687 var c = ca[i]; 688 while (c.charAt(0) == ' ') { 689 c = c.substring(1); 690 } 691 if (c.indexOf(name) == 0) { 692 return c.substring(name.length, c.length); 693 } 694 } 695 return ""; 696}; 697 698YpmPopup.deleteCookie = function (name) { 699 700 document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'; 701}; 702 703YpmPopup.setCookie = function (cName, cValue, exDays, cPageLevel) { 704 705 var expirationDate = new Date(); 706 var cookiePageLevel = ''; 707 var cookieExpirationData = 1; 708 if (!exDays || isNaN(exDays)) { 709 exDays = 365 * 50; 710 } 711 if (typeof cPageLevel == 'undefined') { 712 cPageLevel = false;
713 } 714 expirationDate.setDate(expirationDate.getDate() + exDays); 715 cookieExpirationData = expirationDate.toUTCString(); 716 var expires = 'expires='+cookieExpirationData; 717 718 if (exDays == -1) { 719 expires = '';etCookie 720 } 721 722 if (cPageLevel) { 723 cookiePageLevel = 'path=/;'; 724 } 725 726 var value = cValue + ((exDays == null) ? ";" : "; " + expires + ";" + cookiePageLevel); 727 document.cookie = cName + "=" + value; 728}; 729/* Cookie helper end */ 730 731YpmPopup.getDataById = function (popupId) { 732 var data = YPM_DATA[popupId]; 733 if (!data) {return false} 734 735 return data; 736} 737 738YpmPopup.openPopupById = function (popupId) { 739 var data = YpmPopup.getDataById(popupId); 740 741 if (!data) return false; 742 743 var currentPopup = new YpmPopup(); 744 currentPopup.setPopupId(popupId); 745 currentPopup.setPopupData(data); 746 747 currentPopup.openPopup(popupId); 748} 749 750jQuery(document).ready(function ($) { 751 var ypmObj = new YpmPopup(); 752 ypmObj.init(); 753});
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.