jquery.litebox.js
878 Bytes
// LiteBox v0.1 - jQuery lightbox plugin
(function ($) {
var origin;
var dummy;
$.fn.litebox = function () {
origin = this;
// Create empty div at the place of the original element and replace it
// later when the litebox is closed.
dummy = $('<div></div>').hide().insertBefore(origin).bind('close-litebox', function () {
$(this).replaceWith(origin);
});
$('body').append('<div id="litebox-overlay"></div>');
$('body').append('<div id="litebox"></div>');
origin.appendTo('#litebox');
addEvents();
};
function close() {
$(dummy).trigger('close-litebox');
$('#litebox-overlay').remove();
$('#litebox').remove();
}
function addEvents() {
$('#litebox-overlay').click(function () {
close();
});
}
}(jQuery));