Last active
March 25, 2016 00:40
-
-
Save rugor/a09ef9ffbfc2eb41262f to your computer and use it in GitHub Desktop.
JavaScript, CSS: fancyBox quick-ups
This file contains hidden or 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
<!-- temp lightbox for special event --> | |
<!-- Add fancyBox main JS and CSS files --> | |
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.pack.js"></script> | |
<link rel="stylesheet" type="text/css" href="//cdn.rawgit.com/rugor/fancy-quick/master/jquery.fancybox.css?v=2.1.5" media="screen" /> | |
<script type="text/javascript"> | |
jQuery(document).ready(function ($) { | |
var cookie = document.cookie; | |
if (cookie.indexOf('visited=', 0) == -1) { | |
var expiration = new Date(); | |
expiration.setDate(expiration.getDate()+1); | |
document.cookie = 'visited=1;expires=' + expiration + ';path=/'; | |
$("#hidden_link").fancybox({ | |
helpers: { | |
overlay : { | |
css : { | |
'background' : 'rgba(255,255,255,0.5)' | |
} | |
} | |
}, | |
afterShow: function () { | |
$(".fancybox-image").wrap($("<a />", { | |
href: "http://google.com/", //or your target link | |
target: "_blank" | |
})); | |
} | |
}).trigger("click"); | |
} | |
}); | |
</script> | |
<a id="hidden_link" style="visibility:hidden" href="http://some-image-path.jpg"></a> | |
<!-- end temp lightbox for special event --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment