2013-02-23 04:42:22 +00:00
|
|
|
$(window).load(function() {
|
|
|
|
|
window.lightbox = function(pins) {
|
|
|
|
|
var links = pins.find('.lightbox');
|
|
|
|
|
|
2013-02-23 06:28:02 +00:00
|
|
|
function createBox(boxData) {
|
2013-02-23 04:42:22 +00:00
|
|
|
var template = Handlebars.compile($('#lightbox-template').html());
|
2013-02-23 06:28:02 +00:00
|
|
|
var html = template(boxData);
|
2013-02-23 04:42:22 +00:00
|
|
|
$('body').append(html);
|
|
|
|
|
|
|
|
|
|
$('.lightbox-wrapper img').load(function() {
|
|
|
|
|
$('.lightbox-background').css('height', String($(document).height())+'px');
|
|
|
|
|
$(this).css({
|
|
|
|
|
'max-width': String($(window).width()-200)+'px',
|
2013-02-23 06:28:02 +00:00
|
|
|
'max-height': String($(window).height()-300)+'px',
|
2013-02-23 04:42:22 +00:00
|
|
|
});
|
|
|
|
|
var width = $(this).width();
|
|
|
|
|
$('.lightbox-wrapper').css({
|
2013-02-23 06:28:02 +00:00
|
|
|
'margin-top': String($(window).scrollTop()+100)+'px',
|
2013-02-23 04:42:22 +00:00
|
|
|
'margin-left': '-'+String(width/2)+'px'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return $('.lightbox-background');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var i=0; i < links.length; i++) {
|
|
|
|
|
link = links.eq(i);
|
|
|
|
|
link.off('click');
|
|
|
|
|
link.click(function(e) {
|
2013-02-23 06:28:02 +00:00
|
|
|
var box = createBox({
|
|
|
|
|
image: $(this).attr('href'),
|
|
|
|
|
gravatar: $(this).data('gravatar'),
|
|
|
|
|
username: $(this).data('username'),
|
|
|
|
|
tags: $(this).data('tags').split(',')
|
|
|
|
|
});
|
2013-02-23 04:42:22 +00:00
|
|
|
box.click(function() {
|
|
|
|
|
box.remove()
|
|
|
|
|
});
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|