Added lightbox to post uploads

This commit is contained in:
Marcin Kurczewski 2014-02-20 21:26:46 +01:00
parent 2bac28a553
commit 4b08686393
3 changed files with 47 additions and 10 deletions

View file

@ -155,3 +155,16 @@ ul.tagit {
.post .form-wrapper {
overflow: hidden;
}
#lightbox {
display: none;
position: absolute;
pointer-events: none;
max-width: 400px;
max-height: 400px;
margin-top: -50%;
margin-left: -50%;
background: white;
border: 0.5em solid white;
box-shadow: 0 0 0 3px #eee;
}

View file

@ -180,8 +180,7 @@ $(function()
{
return function(e)
{
img.css('background-image', 'none');
img.attr('src', e.target.result);
changeThumb(img, e.target.result);
};
})(file, img);
reader.readAsDataURL(file);
@ -189,6 +188,14 @@ $(function()
});
}
function changeThumb(img, url)
{
$(img)
.css('background-image', 'none')
.attr('src', url)
.data('custom-thumb', true);
}
function handleURLs(urls)
{
handleInputs(urls, function(postDom, url)
@ -202,18 +209,13 @@ $(function()
{
postDom.find('.file-name strong')
.text(data.data.title);
postDom.find('img')
.css('background-image', 'none')
.attr('src', data.data.thumbnail.hqDefault);
changeThumb(postDom.find('img'), data.data.thumbnail.hqDefault);
});
}
else
{
postDom.find('.file-name strong')
.text(url);
postDom.find('img')
.css('background-image', 'none')
.attr('src', url);
postDom.find('.file-name strong').text(url);
changeThumb(postDom.find('img'), url);
}
});
}
@ -240,4 +242,24 @@ $(function()
else
$('#upload-step2').fadeIn();
}
$('.post img').mouseenter(function(e)
{
if ($(this).data('custom-thumb') != true)
return;
$('#lightbox')
.attr('src', $(this).attr('src'))
.show()
.position({
of: $(this),
my: 'center center',
at: 'center center',
})
.show();
});
$('.post img').mouseleave(function(e)
{
$('#lightbox').hide();
});
});

View file

@ -107,3 +107,5 @@ LayoutHelper::addScript('../lib/tagit/jquery.tagit.js');
</div>
</div>
</div>
<img id="lightbox" src="<?php echo \Chibi\UrlHelper::absoluteUrl('/media/img/pixel.gif') ?>" alt="Preview"/>