jQuery.fn.center = function (position) { this.css("position",(typeof position=='undefined' ? "absolute":position)); var top = (($(window).height() - $(this).outerHeight()) / 2) + $(window).scrollTop(); var left = (($(window).width() - $(this).outerWidth()) / 2) + $(window).scrollLeft(); // top can be negative on mobile devices -- in which case set top statically //alert($(window).height() + " " + $(this).outerHeight() + " " + $(window).scrollTop()); if (top < 0) { top = 40; } this.css("top", top+"px"); this.css("left", left+"px"); return this; } jQuery.fn.animateElement = function (animate, runAfterEffect) { if(typeof runAfterEffect != 'function') { runAfterEffect = function(){} } switch (animate){ case 'up': case 'right': case 'down': case 'left': this.show( "slide", {direction: animate }, 1000 ); break; default: this.fadeIn(); break; } runAfterEffect(); return this; } var additionalData = {impressionId:null, splitId:splitId}; console.log(additionalData); var img = ''; var showName = 0; if(showName==0){ jQuery("#overLay input[name=name]").remove(); } var linkSettings = {"utm":{"campaign":"","source":"","medium":"","content":"","term":""},"popupSettings":"popupTimed","min":"0","sec":"10","mobileTraffic":"","exitTrafficUrl":"http:\/\/www.webfire.com\/a\/?id=26838&p=1","exitTrafficText":"WAIT! Please Don't Go. Check out this All in one Marketing Tool that will \r\nbring in Sales on Autopilot! No Need To Look at Another Marketing Tool Ever\r\nAgain! \r\n\r\nCheck IT Out Now!\r\n\r\nThank you!","geoTargetingAllow":[""],"geoTargetingDeny":[""],"geoTargetingUrl":"http:\/\/","duplicateTraffic":{"campaign":"0","url":"http:\/\/www.wpsalesleads.com"},"trackingCode":"","bannerAnimation":"","bannerText":"","exitTrafficOn":"1","duplicateTrafficOn":"1"}; if(img==''){ var animation = 'down'; } else { var animation = ''; } console.log(linkSettings); function setImpression(id) { var dataToSend = {template:0,splitId:0}; if(theme.selectedTemplate){ dataToSend.template = theme.selectedTemplate; } if(splitId !== null){ dataToSend.splitId = splitId; } var request = $.ajax({ url: "/impressionFor/"+id, data: dataToSend, method: "GET", dataType: "json" }); request.always(function( msg ) { // console.log(msg); }); request.success(function( msg ) { if(msg.impressionId){ impressionId = msg.impressionId; additionalData.impressionId = impressionId; console.log(additionalData.impressionId); } console.log(msg); }); request.fail(function( jqXHR, textStatus ) { console.log(jQuery(jqXHR.responseText).text()); }); } function showRequest(formData, jqForm, options) { var email = ''; jQuery('body').append("
"); return true; } // post-submit callback function showResponse(responseText, statusText, xhr, $form) { /* jQuery('body').append('
'); jQuery('#overLay').text(jQuery(responseText).text()); jQuery('div#console').html(responseText); */ console.log(responseText); if(responseText.url) { window.location = responseText.url; } jQuery('#overLay').slideUp('slow'); jQuery('#loading').remove(); } function showImage(){ var top = (($(window).height() - $(this).outerHeight()) / 2) + $(window).scrollTop(); console.log(top); jQuery('#bannerImg').css('width', jQuery(this).css('width')).css('height', jQuery(this).css('height')).css('top', top+"px"); } var $overlay = jQuery('#overLay'); jQuery(document).ready(function(){ jQuery(window).on('resize', function(){ if(img==''){ $overlay.center(); } }); if(linkSettings.exitTrafficOn == "1" || linkSettings.popupSettings == 'popupExit'){ var _ouibounce = ouibounce(null, { aggressive: true, callback: function() { if(jQuery("#modal").length>0){ jQuery("#modal").modal(); } if(linkSettings.popupSettings=='popupExit'){ if(img==''){ $overlay.center(); } $overlay.animateElement(animation); } } }); } /* if(linkSettings.duplicateTrafficOn == "1") { var visitor = readCookie('_visitor'); if(visitor === null){ createCookie('_visitor', 'true', 365); } else { if(linkSettings.duplicateTraffic.url==''){ window.location = linkSettings.duplicateTraffic.url; } else { } } } else { eraseCookie('_visitor'); } */ jQuery('#mf').ready(function(){ if(linkSettings.popupSettings){ switch(linkSettings.popupSettings){ case 'popupTimed': case 'popupLocked': case 'popupPage': var showUp = 0; var min = parseInt(linkSettings.min); var sec = parseInt(linkSettings.sec); if( min ){ showUp += min*60*1000; } if(sec){ showUp += sec*1000; } if(linkSettings.popupSettings == 'popupLocked') { $overlay.children('.close').remove(); showUp = 0; } if(linkSettings.popupSettings == 'popupPage') { showUp = 0; } setTimeout(function(){ if(img==''){ $overlay.center(); } $overlay.animateElement(animation); setImpression(1865); }, showUp); break; default: break; } } jQuery('.close').on('click', function(){ jQuery(this).parent().slideUp(); jQuery("#closedOverlay").css('visibility', 'visible'); }); jQuery("#closedOverlay").on('click', function(){ jQuery(this).css('visibility', 'hidden'); jQuery('#overLay').show(); }); }); var options = { target: '#output', // target element(s) to be updated with server response beforeSubmit: showRequest, // pre-submit callback success: showResponse, // post-submit callback data: additionalData, error: function(response, textStatus, thrown){ jQuery('#loading').remove(); jQuery('#overLay').slideUp('slow'); jQuery('body').append('
'); jQuery('#overLay').text(jQuery(response.responseText).text()); jQuery('div#console').html(response.responseText); var urlToGoTo = 'http://jvz9.com/c/207085/232957'; if(urlToGoTo) { window.location = urlToGoTo; } }, // other available options: url: '/subscribe/to/1865', type: 'post', dataType: 'json', clearForm: true, resetForm: true, timeout: 50000 }; jQuery('#overLay form').ajaxForm(options); jQuery('#overLay #bannerImg').on('click', function(e){ e.preventDefault(); var $banner = jQuery(this); var request = $.ajax({ url: "/bannerFor/1865", method: "POST", dataType: "json" }); request.always(function( msg ) { window.location = $banner.attr('href'); }); request.success(function( msg ) { console.log(msg); }); request.fail(function( jqXHR, textStatus ) { console.log("Error!"); }); }); }); function createCookie(name,value,days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); expires = "; expires="+date.toGMTString(); } document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); }