FIX - фоторама при одной фотке

This commit is contained in:
Krivchikov Dmitry 2015-05-27 23:50:34 +03:00
parent 8df0cf677a
commit 429fb895cf
1 changed files with 12 additions and 14 deletions

View File

@ -78,19 +78,19 @@ function closeBox()
function showImage(id) function showImage(id)
{ {
point = pointsSources[id]; point = pointsSources[id];
photos = [];
if( typeof($('.fotorama').data('fotorama')) != 'undefined' )
{
$('.fotorama').data('fotorama').destroy();
}
$('#imageModalLabel').text(point.name); $('#imageModalLabel').text(point.name);
$('#imageModalImg').hide();
$('.fotorama').show();
if (typeof(point.images) == 'object') if (typeof(point.images) == 'object')
{ {
if( typeof($('.fotorama').data('fotorama')) != 'undefined' )
{
$('.fotorama').data('fotorama').destroy();
}
$('#imageModalImg').hide();
$('.fotorama').show();
photos = [];
point.images.forEach(function(entry) { point.images.forEach(function(entry) {
if (window.devicePixelRatio > 1) { if (window.devicePixelRatio > 1) {
photos.push({img: '/photos/big/'+entry, thumb: '/photos/small/'+entry}); photos.push({img: '/photos/big/'+entry, thumb: '/photos/small/'+entry});
@ -98,13 +98,11 @@ function showImage(id)
photos.push({img: '/photos/middle/'+entry, thumb: '/photos/small/'+entry}); photos.push({img: '/photos/middle/'+entry, thumb: '/photos/small/'+entry});
} }
}); });
initFotorama('.fotorama', photos);
} else { } else {
$('#imageModalImg').attr('src', point.img); photos.push({img: point.img, thumb: point.img});
$('#imageModalImg').show();
$('.fotorama').hide();
} }
initFotorama('.fotorama', photos);
$('#imageModal').modal('show'); $('#imageModal').modal('show');
} }