Skip to content

Instantly share code, notes, and snippets.

@testlabauto
Created February 28, 2018 18:35
Show Gist options
  • Save testlabauto/3d32b6c8f82114d5f64224c51df86994 to your computer and use it in GitHub Desktop.
Save testlabauto/3d32b6c8f82114d5f64224c51df86994 to your computer and use it in GitHub Desktop.
jQuery(document).ready(function($) {
setTimeout( open_wcsd_modal, wcsd.delay*1000 );
function open_wcsd_modal() {
if( jQuery('#wcsd_modal').length > 0 ){
var overlayClick = wcsd.overlay_click == 'yes' ? true : false;
jQuery.magnificPopup.open({
items: {
src: '#wcsd_modal'
},
type: 'inline',
removalDelay: 1000,
closeOnBgClick: overlayClick,
callbacks: {
beforeOpen: function() {
this.st.mainClass = wcsd.effect;
},
beforeClose: function() {
if( wcsd.hinge == 'yes' )
this.content.addClass('hinge');
else
jQuery('.mfp-wrap').css('background', 'transparent');
},
close: function() {
if( wcsd.hinge == 'yes' )
this.content.removeClass('hinge');
},
open: function(){
jQuery('.mfp-wrap').css('background', wcsd.overlayColor);
wcsd_setCookie( 'wcsd_closed', 'yes', wcsd.cookie_length );
}
}
});
}
}
// Set Cookie
function wcsd_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 + "; " + expires +"; path=/";
}
// Get Cookie
function wcsd_getCookie(cname) {
var name = cname + "=";
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);
if (c.indexOf(name) != -1) return c.substring(name.length,c.length);
}
return "";
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment