let getURL = window.location.href;
let setHost = window.location.host;
// console.log('getURL', getURL);
if(getURL.startsWith('https://'+ setHost +'/resource-center/')){
// alert('test >>>>>');
if (typeof($) == "undefined") {
// DOM: Create the script element
var jsElm = document.createElement("script");
jsElm.type = "application/javascript";
jsElm.integrity = "sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=";
jsElm.crossOrigin = "anonymous"
// make the script element load file
jsElm.src = 'https://code.jquery.com/jquery-3.4.1.min.js';
// finally insert the element to the body element in order to load the script
// document.body.appendChild(jsElm);
}
var jqueryInterval = setInterval(function () {
if (typeof ($) != "undefined") {
clearInterval(jqueryInterval);
if ($('body').hasClass('single-webinar')) {
return;
}
//$('body').addClass('single-webinar');
exitIntentModelHTML();
}
});
function exitIntentModelHTML(){
$('body').prepend('
\
\
\
\
\
Stay Up-to-Date With \
Our HR Newsletter \
\
Guides - receive timely advice on trending HR topics \
Compliance - get updates on the latest regulation changes. \
Templates - streamline your operations with best-practice templates. \
\
\
\
\
\
Check your inbox for an email confirming your subscription. \
Enjoy! \
\
\
\
\
Close \
\
\
\
\
\
\
');
$('#modal-upgrade .modal-close, #modal-upgrade .traffic-link a, .modal-upgrade .modal-contanier .col-success .cBtn').click(function() {
closeModel();
});
// window.onclick = function(event) {
// if (event.target == document.getElementsByClassName("modal-content-wrap")[0] ){
// $('#modal-upgrade .modal-close').trigger("click");
// }
// }
var modalOpen = 0;
var onceInDayCookieKey = 'spz_once_in_day_beforeYouGo';
function openModal(){
var modalCookiesVal = getCookie('spz_once_in_day_beforeYouGo');
if(modalCookiesVal != '1') {
modalOpen = 1;
if($('#modal-upgrade').length == 0){
exitIntentModelHTML();
}
if($('#modal-upgrade').length){
$('body').addClass('modal-open');
$('#modal-upgrade').addClass('in');
setCookie(onceInDayCookieKey, '1', 1);
}
if($('.subscribe-form .wp-block-ws-form form#mktoForm_2868').length){
var fragment = document.createDocumentFragment();
fragment.appendChild(document.querySelector('.subscribe-form .wp-block-ws-form form'));
if($(".modal-upgrade .modal-contanier .col-form from").length == 0){
document.querySelector('.modal-upgrade .modal-contanier .col-form').appendChild(fragment);
}
$('.modal-upgrade #mktoForm_2868.mktoForm .mktoButtonWrap .mktoButton').text('Subscribe');
$('.modal-upgrade .col-form #mktoForm_2868.mktoForm .mktoFormRow').each(function() {
if($(this).find('.mktoField').attr('type') == 'hidden') {
$(this).addClass('hideField');
}else{
$(this).addClass($(this).find('.mktoField').attr('id') + '-row');
}
var getLabelName = $(this).find('.mktoField').attr('placeholder');
$(this).find('.mktoFieldWrap .mktoLabel').html(getLabelName);
if($(this).find('.mktoField').attr('id') == 'Email') {
$(this).addClass($(this).find('.mktoField').attr('id') + '-row');
}
});
}
if($(".subscribe-box .wp-block-ws-form form#mktoForm_2868").length){
var fragment = document.createDocumentFragment();
fragment.appendChild(document.querySelector('.subscribe-box .wp-block-ws-form form'));
if($(".modal-upgrade .modal-contanier .col-form from").length == 0){
document.querySelector('.modal-upgrade .modal-contanier .col-form').appendChild(fragment);
}
$('.modal-upgrade #mktoForm_2868.mktoForm .mktoButtonWrap .mktoButton').text('Subscribe');
$('.modal-upgrade .col-form #mktoForm_2868.mktoForm .mktoFormRow').each(function() {
if($(this).find('.mktoField').attr('type') == 'hidden') {
$(this).addClass('hideField');
}else{
$(this).addClass($(this).find('.mktoField').attr('id') + '-row');
}
var getLabelName = $(this).find('.mktoField').attr('placeholder');
$(this).find('.mktoFieldWrap .mktoLabel').html(getLabelName);
if($(this).find('.mktoField').attr('id') == 'Email') {
$(this).addClass($(this).find('.mktoField').attr('id') + '-row');
}
});
}
if($('#modal-upgrade').hasClass('hasForm')){
$('#mktoForm_2868').parent().addClass('subForm');
/* $('#mktoForm_2868').appendTo('.modal-upgrade .col-form');
$('.single-webinar .subscribe-form .wp-block-ws-form').html('');*/
MktoForms2.whenReady(function (form) {
var form_id = form.getId();
if(form_id == "2868"){
// Focus Function
var inputSelector = '#mktoForm_2868.mktoForm input.mktoField';
var selectSelector = '#mktoForm_2868.mktoForm select.mktoField';
var selector = inputSelector + ', ' + selectSelector;
// Initial Class Added
$(document).on('focus', selector, function () {
$(this).closest('.mktoFieldWrap').addClass('active typing');
});
$(document).on('change blur', selector, function(e) {
if ($(this).val() == null || $(this).val() == '') {
$(this).closest('.mktoFieldWrap').removeClass('active');
} else{
$(this).closest('.mktoFieldWrap').addClass('active');
}
if(e.type == 'focusout') {
if($(this).closest('.mktoFieldWrap').find('#Email').length > 0) {
validateMarketoEmail1();
}
$(this).closest('.mktoFieldWrap').removeClass('typing');
}
});
$(selector).each(function () {
if ($(this).val() == null || $(this).val() == '') {
$(this).closest('.mktoFieldWrap').removeClass('active');
} else {
$(this).closest('.mktoFieldWrap').addClass('active');
}
});
$(selectSelector).change(function () {
if ($(this).val() == null || $(this).val() == '') {
$(this).closest('.mktoFieldWrap').removeClass('active');
} else {
$(this).closest('.mktoFieldWrap').addClass('active');
}
});
$('.single-webinar .col-form #mktoForm_2868.mktoForm').on('DOMSubtreeModified', function() {
reCheckValidation();
});
// Email Validation
function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
var validateMarketoEmail1 = function() {
var email = form.vals().Email;
var emailElem = form.getFormElem().find("#Email");
$(".form-model .mktoForm .mktoFieldWrap .mktoError").hide();
if (!validateEmail(email)) {
form.submitable(false);
form.showErrorMessage('Must be valid email. example@yourdomain.com ', emailElem);
emailElem.addClass("mktoInvalid");
emailElem.removeClass("mktoValid");
return false;
} else {
form.submitable(true);
emailElem.removeClass("mktoInvalid");
emailElem.addClass("mktoValid");
}
reCheckValidation();
}
form.getFormElem().find("#Email").keyup(validateMarketoEmail1);
form.onValidate(function() {
validateMarketoEmail1();
});
form.onSuccess(function(values, followUpUrl){
//get the form's jQuery element and hide it
form.getFormElem().hide();
$('.single-webinar .subForm .form-msg').text('Check your inbox for an email confirming your subscription.').css('display','block');
$('.modal-upgrade .modal-contanier').addClass('submitted');
$('.reset_form_mrketo').click();
//return false to prevent the submission handler from taking the lead to the follow up url.
return false;
});
}
});
}
}
}
function closeModel(){
modalOpen = 0;
$('body').removeClass('modal-open');
$('#modal-upgrade').removeClass('in').fadeOut();
var fragment = document.createDocumentFragment();
if($(".subscribe-form .wp-block-ws-form").length){
fragment.appendChild(document.querySelector('.modal-upgrade .modal-contanier .col-form .mktoForm'));
document.querySelector('.subscribe-form .wp-block-ws-form').appendChild(fragment);
$('.subscribe-form .mktoForm .mktoButtonRow .mktoButton').text('Subscribe Now');
$(".subscribe-form .wp-block-ws-form form").show();
$(".subscribe-form .wp-block-ws-form form input#Email + .mktoError").hide();
}
if($(".subscribe-box .wp-block-ws-form").length){
fragment.appendChild(document.querySelector('.modal-upgrade .modal-contanier .col-form .mktoForm'));
document.querySelector('.subscribe-box .wp-block-ws-form').appendChild(fragment);
$('.subscribe-box .mktoForm .mktoButtonRow .mktoButton').text('Subscribe Now');
$(".subscribe-box .wp-block-ws-form form").show();
$('.subscribe-box .mktoForm label#LblEmail').hide();
$(".subscribe-box .wp-block-ws-form form input#Email + .mktoError").hide();
}
/*if($('#modal-upgrade').hasClass('hasForm')){
$('#mktoForm_2868').appendTo('.single-webinar .subscribe-form .wp-block-ws-form');
$('.modal-upgrade .col-form').html('');
}*/
}
function exitIntentPopup(){
var mouseY = 0;
var topValue = 10;
window.addEventListener("mouseout",function(e) {
mouseY = e.clientY;
if (mouseY <= topValue && modalOpen == 0) {
openModal();
}
}, false);
}
// Get Cookies
function getCookie(name) {
var v = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
return v ? v[2] : null;
}
// For one day cookie
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";secure;" + expires + ";domain="+ setHost +";path=/";
}
exitIntentPopup();
if(typeof(MktoForms2) != "undefined" && $('#mktoForm_2868').length > 0){
console.log("if condition");
$('.modal-upgrade').addClass('hasForm');
}else{
console.log("else condition");
// $('.modal-upgrade .col-form').append('');
$.getScript('//go.paycor.com/js/forms2/js/forms2.min.js', function(){
if($(".block-filter__row article").length || $(".archive-results.archive-results-box").length || $("section.wp-block-ws-section.featured_resources_main.resource_slider").length){
if($('.modal-upgrade .col-form .mktoForm').length == 0 && $("#mktoForm_2868").length == 0){
$('.modal-upgrade .col-form').append('');
MktoForms2.loadForm("//go.paycor.com", "003-JWW-697", 2868);
}
}
// MktoForms2.loadForm("//go.paycor.com", "003-JWW-697", 2868);
MktoForms2.whenReady(function (form) {
if($('#modal-upgrade').length == 0){
exitIntentPopup();
}
var form_id = form.getId();
if(form_id == "2868"){
/*var fragment = document.createDocumentFragment();
fragment.appendChild(document.querySelector('.subscribe-form .wp-block-ws-form form'));
document.querySelector('.modal-upgrade .modal-contanier .col-form').appendChild(fragment);*/
$('.modal-upgrade #mktoForm_2868.mktoForm .mktoButtonWrap .mktoButton').text('Subscribe');
$('.modal-upgrade .col-form #mktoForm_2868.mktoForm .mktoFormRow').each(function() {
if($(this).find('.mktoField').attr('type') == 'hidden') {
$(this).addClass('hideField');
}else{
$(this).addClass($(this).find('.mktoField').attr('id') + '-row');
}
var getLabelName = $(this).find('.mktoField').attr('placeholder');
$(this).find('.mktoFieldWrap .mktoLabel').html(getLabelName);
if($(this).find('.mktoField').attr('id') == 'Email') {
$(this).addClass($(this).find('.mktoField').attr('id') + '-row');
}
});
// Focus Function
var inputSelector = '#mktoForm_2868.mktoForm input.mktoField';
var selectSelector = '#mktoForm_2868.mktoForm select.mktoField';
var selector = inputSelector + ', ' + selectSelector;
// Initial Class Added
$(document).on('focus', selector, function () {
$(this).closest('.mktoFieldWrap').addClass('active typing');
});
$(document).on('change blur', selector, function(e) {
if ($(this).val() == null || $(this).val() == '') {
$(this).closest('.mktoFieldWrap').removeClass('active');
} else{
$(this).closest('.mktoFieldWrap').addClass('active');
}
if(e.type == 'focusout') {
if($(this).closest('.mktoFieldWrap').find('#Email').length > 0) {
validateMarketoEmail1();
}
$(this).closest('.mktoFieldWrap').removeClass('typing');
}
});
$(selector).each(function () {
if ($(this).val() == null || $(this).val() == '') {
$(this).closest('.mktoFieldWrap').removeClass('active');
} else {
$(this).closest('.mktoFieldWrap').addClass('active');
}
});
$(selectSelector).change(function () {
if ($(this).val() == null || $(this).val() == '') {
$(this).closest('.mktoFieldWrap').removeClass('active');
} else {
$(this).closest('.mktoFieldWrap').addClass('active');
}
});
$('.single-webinar .col-form #mktoForm_2868.mktoForm').on('DOMSubtreeModified', function () {
reCheckValidation();
});
// Email Validation
function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
var validateMarketoEmail1 = function() {
var email = form.vals().Email;
var emailElem = form.getFormElem().find("#Email");
$(".form-model .mktoForm .mktoFieldWrap .mktoError").hide();
if (!validateEmail(email)) {
form.submitable(false);
form.showErrorMessage('Must be valid email. example@yourdomain.com ', emailElem);
emailElem.addClass("mktoInvalid");
emailElem.removeClass("mktoValid");
emailElem.closest('.mktoFieldWrap').addClass('error');
return false;
} else {
form.submitable(true);
emailElem.removeClass("mktoInvalid");
emailElem.addClass("mktoValid");
emailElem.closest('.mktoFieldWrap').removeClass('error');
}
reCheckValidation();
}
form.getFormElem().find("#Email").keyup(validateMarketoEmail1);
form.onValidate(function() {
validateMarketoEmail1();
});
form.onSuccess(function(values, followUpUrl){
//get the form's jQuery element and hide it
form.getFormElem().hide();
$('.modal-upgrade .modal-contanier').addClass('submitted');
$('.modal-upgrade .modal-contanier.submitted .col-content').after(' ');
$('.modal-upgrade .submitted .modal-close').click(function() {
closeModel();
});
//return false to prevent the submission handler from taking the lead to the follow up url.
return false;
});
}
});
});
}
function reCheckValidation() {
setTimeout(function () {
var errorShownFound = false;
$('.mktoForm .mktoFieldWrap').each(function () {
if ($(this).find('.mktoError').length > 0 && $(this).find('.mktoError').css('display') != 'none' && errorShownFound == false) {
// $(this).addClass('error');
errorShownFound = true;
} else {
// $(this).removeClass('error');
}
});
}, 100);
}
}
}