var oldScrollY = 0;
function damageLogo(execution)
{
var timer = 30;
if (execution > 9)
timer = 400;
$('#logo span').animate({
opacity: Math.random().toFixed(2)
},
timer,
function()
{
if (execution > 10)
noLogo();
else
damageLogo(execution + 1)
});
}
function noLogo()
{
$('#logo span').css('opacity', 0);
$('#logo span').text('UBATECH');
setTimeout(function() { fixLogo(); }, 1200);
}
function fixLogo()
{
$('#logo span').animate({
opacity: 1
},
800);
$('#logo img').animate({
opacity: 1
},
800,
function(){
$('#logo span').text('UBATECH');
});
}
$(function(){
var nbsp = ' ';
noLogo();
var page = 'kuchnie';
$.getJSON("/json/" + page + ".json",
function( data ) {
$("#imageWrapper").html('');
$.each(data.Pictures, function(i, value){
var card = '\
\
\
\
\
${value.description}
\
';
// IE compatibility :(
card = card.replace('${value.img}', value.img);
card = card.replace('${value.smimg}', value.smimg);
card = card.replace('${value.description}', value.description);
card = card.replace('${value.alt}', value.description);
$("#imageWrapper").append( card );
});
//Image Gallery
// ACTIVITY INDICATOR
var activityIndicatorOn = function()
{
$( '' ).appendTo( 'body' );
},
activityIndicatorOff = function()
{
$( '#imagelightbox-loading' ).remove();
},
// OVERLAY
overlayOn = function()
{
$( '' ).appendTo( 'body' );
},
overlayOff = function()
{
$( '#imagelightbox-overlay' ).remove();
},
// CLOSE BUTTON
closeButtonOn = function( instance )
{
$( '' ).appendTo( 'body' ).on( 'click touchend', function(){ $( this ).remove(); instance.quitImageLightbox(); return false; });
},
closeButtonOff = function()
{
$( '#imagelightbox-close' ).remove();
},
// CAPTION
captionOn = function()
{
var description = $( 'a[href="' + $( '#imagelightbox' ).attr( 'src' ) + '"] img' ).attr( 'alt' );
if( description.length > 0 )
$( '' + description + '
' ).appendTo( 'body' );
},
captionOff = function()
{
$( '#imagelightbox-caption' ).remove();
},
// NAVIGATION
navigationOn = function( instance, selector )
{
var images = $( selector );
if( images.length )
{
var nav = $( '' );
for( var i = 0; i < images.length; i++ )
nav.append( '' );
nav.appendTo( 'body' );
nav.on( 'click touchend', function(){ return false; });
var navItems = nav.find( 'button' );
navItems.on( 'click touchend', function()
{
var $this = $( this );
if( images.eq( $this.index() ).attr( 'href' ) != $( '#imagelightbox' ).attr( 'src' ) )
instance.switchImageLightbox( $this.index() );
navItems.removeClass( 'active' );
navItems.eq( $this.index() ).addClass( 'active' );
return false;
})
.on( 'touchend', function(){ return false; });
}
},
navigationUpdate = function( selector )
{
var items = $( '#imagelightbox-nav button' );
items.removeClass( 'active' );
items.eq( $( selector ).filter( '[href="' + $( '#imagelightbox' ).attr( 'src' ) + '"]' ).index( selector ) ).addClass( 'active' );
},
navigationOff = function()
{
$( '#imagelightbox-nav' ).remove();
},
// ARROWS
arrowsOn = function( instance, selector )
{
var $arrows = $( '' );
$arrows.appendTo( 'body' );
$arrows.on( 'click touchend', function( e )
{
e.preventDefault();
var $this = $( this ),
$target = $( selector + '[href="' + $( '#imagelightbox' ).attr( 'src' ) + '"]' ),
index = $target.index( selector );
if( $this.hasClass( 'imagelightbox-arrow-left' ) )
{
index = index - 1;
if( !$( selector ).eq( index ).length )
index = $( selector ).length;
}
else
{
index = index + 1;
if( !$( selector ).eq( index ).length )
index = 0;
}
instance.switchImageLightbox( index );
return false;
});
},
arrowsOff = function()
{
$( '.imagelightbox-arrow' ).remove();
};
var selector = '.slideShower';
var instance = $(selector).imageLightbox({
onStart:function() { overlayOn(); closeButtonOn( instance ); arrowsOn( instance, selector ); },
onEnd:function() { overlayOff(); captionOff(); closeButtonOff(); arrowsOff(); activityIndicatorOff(); },
onLoadStart:function() { captionOff(); activityIndicatorOn(); },
onLoadEnd:function() { captionOn(); activityIndicatorOff(); $( '.imagelightbox-arrow' ).css( 'display', 'block' ); }
});
}
);
});