Created
November 17, 2016 12:19
-
-
Save oliwa/36b4c8720b541a6f09516b49e60c2a2d to your computer and use it in GitHub Desktop.
Magnific Popupwith delayed opening, Cookie to switch off
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="advertisement" class="mfp-hide"> | |
<div class="wrap group text-center"> | |
<img src="http://placehold.it/800x600"/> | |
<p><a href="javascript:;" id="closeAd" class="button"><i class="fa fa-close"></i> Nicht mehr anzeigen</a></p> | |
</div> | |
</div> | |
<script src="<?php bloginfo('template_directory'); ?>/js/jquery.cookie.js"></script> | |
<script> | |
$(document).ready(function () { | |
if ($.cookie('doNotShowAd')) | |
//alert('Cookie gesetzt, kein Popup'); | |
console.log('Cookie gesetzt, kein Popup'); | |
else { | |
setTimeout(function() { | |
if ($('#advertisement').length) { | |
$.magnificPopup.open({ | |
items: { | |
src: '#advertisement' | |
}, | |
type: 'inline', | |
closeBtnInside: false, | |
}); | |
} | |
}, 5000); | |
} | |
$("#closeAd").click(function() { | |
$.magnificPopup.close(); | |
$.cookie('doNotShowAd', true); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment