Check if Fancybox is initialized
HTML
<script src="http://thegeekinvasion.com/wp-content/plugins/tgi-fancybox/fancybox/jquery.fancybox.pack.js"></script>
<link rel="stylesheet" href="http://thegeekinvasion.com/wp-content/plugins/tgi-fancybox/fancybox/jquery.fancybox.pack.css">
<input id="check-fb" type="button" value="Check FB" />
<span id="status"></span>
CSS
html {
color: #777;
font-size: 0.9em;
}
a {
float:left;
margin-right:5px;
}
a:last-child {
margin-right:0;
}
em {
background:#eee;
font-style:normal;
}
hr, div, p {
margin:30px 0 0;
}
img {
max-height:137px;
}
input {
font-size:12px;
margin-top:10px;
padding:10px 20px;
}
label, .legend p {
color:#555;
font:0.8em sans-serif;
}
p {
font-family:sans-serif;
}
strong {
font-style:inherit;
font-weight:bold;
}
sup {
color:#c00;
font:bold 10px sans-serif;
margin:-5px 7px 0 2px;
}
.check {
font-weight:bold;
}
.clear {
clear:both;
}
.desc {
font-size: 1.2em;
font-style:italic;
text-align:justify;
}
.fb-buttons {
margin-top:10px;
width:100%;
}
.fb-container {
margin-left:auto;
margin-right:auto;
}
.fb-status {
background:#ddd;
padding:10px 20px;
}
.fb-status p {
margin-top:10px;
}
.fb-status p:last-child {
margin-bottom:10px;
}
.heading {
font-size: 1.5em;
}
.wrap {
margin-left:auto;
margin-right:auto;
width:90%;
}
JavaScript
jQuery(function ($) {
function fancyboxIsInit() {
var fbInit = false;
if (typeof $._data(document, "events") !== "undefined") {
$.each($._data(document, "events").click, function (i, v) {
if (v.namespace === 'fb-start') fbInit = true;
});
}
return fbInit;
}
function fbCheck() {
$(".check").each(function () {
if ($(this).text() === "false" || $(this).text().search(/not/i) > -1) $(this).css("color", "#c00");
else $(this).css("color", "green");
});
}
$(window).load(function () {
var load = Math.random() < 0.5,
typeOf, clicks;
if (load) $(".fancybox").fancybox();
$(".status .check").text(load ? "loaded" : "not loaded");
fbCheck();
$("#check-fb").on("click.checkFb", function () {
typeOf = typeof $.fancybox == 'function' ? "true" : "false";
clicks = fancyboxIsInit() ? "true" : "false";
$("span.typeof").html(typeOf);
$("span.events").html(clicks);
fbCheck();
});
var w = 0;
$(".fb-container .fancybox").each(function() {
w += $(this).outerWidth(true);
});
$(".fb-container").width(w);
});
});