if(typeof(window.galleryObjects) == 'undefined'){ window.galleryObjects = {}; } function initGallery(listId){ var listId = jQuery('#pictureGallery_' + listId).data('listid'); var fadeTime = jQuery('#pictureGallery_' + listId).data('fadetime'); var animation = jQuery('#pictureGallery_' + listId).data('animation'); var animationDuration = jQuery('#pictureGallery_' + listId).data('animationduration'); var previewAnimation = jQuery('#pictureGallery_' + listId).data('previewanimation'); var previewAnimationDirection = jQuery('#pictureGallery_' + listId).data('previewanimationdirection'); var numberEntries = jQuery('#pictureGallery_' + listId).data('numberentries'); var currentEntry = jQuery('#pictureGallery_' + listId).data('currententry'); var useFancybox = jQuery('#pictureGallery_' + listId).data('usefancybox'); if(useFancybox == 'yes'){ var position = 0; jQuery('#listEntriesPreview_' + listId + ' .listEntry').each(function(){ var srcFancybox = jQuery(this).data('src-detail') if(typeof srcFancybox == 'undefined'){ srcFancybox = jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position) + ')').find('img.listEntryImage').attr('src'); } var titleFancybox = jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position) + ')').find('img.listEntryImage').attr('title'); if(typeof titleFancybox == 'undefined'){ titleFancybox = jQuery(this).find('img.listEntryImage').attr('title'); } var titleFancyboxEncoded = ''; if(typeof titleFancybox != 'undefined'){ titleFancyboxEncoded = titleFancybox.replace(//g, '>').replace(/"/g, '"').replace(/#/g, ''); } jQuery(this).wrap(''); jQuery(this).find('.beButtonDeleteRow, .beButtonEditRow').click(function(e){ e.stopPropagation(); return false; }) position++; }); } onAfterSelectListEntryGallery(listId, 0); //console.log(animation); if(typeof(fadeTime) != 'undefined' && fadeTime != '' && fadeTime != 0){ jQuery('#pictureGallery_' + listId).data('intervalcount', 1); window.galleryObjects[listId] = {'interval' : window.setInterval(function(){jQuery('#pictureGallery_' + listId).data('intervalcount', jQuery('#pictureGallery_' + listId).data('intervalcount') + 1);if(jQuery('#pictureGallery_' + listId).data('intervalcount') >= 128){window.clearInterval(window.galleryObjects[listId]['interval'])};selectListEntryGallery(listId, "+")}, fadeTime * 1000)}; jQuery(window).blur(function(){ window.clearInterval(window.galleryObjects[listId]['interval']); }); jQuery(window).focus(function(){ window.clearInterval(window.galleryObjects[listId]['interval']); window.galleryObjects[listId] = {'interval' : window.setInterval(function(){jQuery('#pictureGallery_' + listId).data('intervalcount', jQuery('#pictureGallery_' + listId).data('intervalcount') + 1);if(jQuery('#pictureGallery_' + listId).data('intervalcount') >= 128){window.clearInterval(window.galleryObjects[listId]['interval'])};selectListEntryGallery(listId, "+")}, fadeTime * 1000)}; }); } if(animation == 'collage'){ jQuery('#listEntries_' + listId).data('numberChanged', 0); jQuery('#listEntries_' + listId + ' .listEntry').each(function(){ //jQuery(this).click(function(){eval('selectEntry_' + listId + '(' + jQuery('#listEntries_' + listId).data('numberChanged') + ')');}); if(jQuery('#listEntries_' + listId).data('numberChanged') != 0){ jQuery(this).css({'transform': 'rotate(' + parseInt(Math.random() * 30 - 15) + 'deg)'}); } jQuery(this).css({'z-index' : parseInt(1000 - jQuery('#listEntries_' + listId).data('numberChanged'))}); jQuery('#listEntries_' + listId).data('numberChanged', jQuery('#listEntries_' + listId).data('numberChanged') + 1); }); } else if(animation == 'carouselhorizontal'){ jQuery('#listEntries_' + listId + ' .listEntry').each(function(index){ var widthEntryRel = Math.round(100 * parseInt(jQuery(this).css('width')) / parseInt(jQuery(this).parent().css('width'))) / 100; //console.log(widthEntryRel); if(widthEntryRel < 0.1){ widthEntryRel = 0.7; } jQuery(this).data('width-entry-rel', widthEntryRel); jQuery(this).click(function(){ selectListEntryGallery(listId, index, {'positionEntry' : jQuery(this).index() + 1}); }); }); selectListEntryGallery(listId, currentEntry, {'init' : true}); } if(previewAnimation == 'ticker'){ var options = new Array(); options['repeatMode'] = 'continue'; options['delayStart'] = 2; options['duration'] = (animationDuration ? animationDuration : 600); jQuery('#listEntries_' + listId).data('numberChanged', 0); var tickerData = new Array(); jQuery('#listEntriesPreview_' + listId + ' .listEntry').each(function(){ tickerData.push($(this).children()[0]); }); var multi = 2; if(tickerData.length == 1){ multi = 6; } else if(tickerData.length == 2){ multi = 4; } else if(tickerData.length == 3){ multi = 3; } jQuery('#listEntriesPreview_' + listId + ' ').data('hasFinishedLoop', '1'); window.setTimeout(function(){ var containerInner = jQuery('#listEntriesPreview_' + listId + ' '); var containerOuter = containerInner.parent(); var widthContainerInner = containerInner.width(); var duration = widthContainerInner * options['duration'] / 50; var clonedNodes = new Array(); jQuery('#listEntriesPreview_' + listId + ' .listEntry').each(function(){ clonedNodes.push(jQuery(this)); }); for(m = 0; m < multi; m++){ for(i = 0; i < clonedNodes.length; i++){ containerInner.append(clonedNodes[i].clone()); } } var lastElementInner = containerInner.children('*:last'); var offsetRightLastElementInner = lastElementInner.get(0).offsetLeft + lastElementInner.outerWidth() + parseInt(lastElementInner.css('margin-right')); containerInner.css({'width' : String(offsetRightLastElementInner) + 'px'}); widthContainerInner = containerInner.width(); jQuery('html, body').bind('touchstart', function(){ containerInner.stop(); }); jQuery('html, body').bind('touchend', function(){ containerInner.data('hasFinishedLoop', '1'); }); if(previewAnimationDirection == 'ltr'){ var animationWidth = widthContainerInner / multi; var initLeft = '-' + animationWidth + 'px'; containerInner.css('margin-left', initLeft); window.setInterval(function(){ if(containerInner.data('hasFinishedLoop') == '1'){ containerInner.data('hasFinishedLoop', '0'); containerInner.animate({'marginLeft': '0px'}, duration / (2 * multi), 'linear', function(){ containerInner.css('margin-left', initLeft); containerInner.data('hasFinishedLoop', '1'); }); } }, 100); } else{ window.setInterval(function(){ if(containerInner.data('hasFinishedLoop') == '1'){ containerInner.data('hasFinishedLoop', '0'); containerInner.animate({'marginLeft': '-' + String(widthContainerInner / multi) + 'px'}, duration / (2 * multi), 'linear', function(){ containerInner.css('margin-left', '0px'); containerInner.data('hasFinishedLoop', '1'); }); } }, 100); } }, parseInt(options['delayStart']) * 1000); } else if(previewAnimation == 'scrollhorizontal'){ jQuery('#list_' + listId + ' .listMoverBack').removeAttr('onclick').click(function(){ var parentWidth = jQuery('#listEntriesPreview_' + listId + ' ').parent().width(); var movingMax = - parseInt(jQuery('#listEntriesPreview_' + listId + ' ').css('margin-left')); var movingWidth = parentWidth > movingMax ? movingMax : parentWidth; var entryWidth = jQuery('#listEntriesPreview_' + listId + ' .listEntry').outerWidth(true); var rasterMod = parentWidth % entryWidth; var rasterRest = rasterMod; //console.log(entryWidth + ' ' + rasterMod); //console.log('< ' + parentWidth + ' > ' + movingMax + ' = ' + movingWidth); if(parentWidth < movingMax){ movingWidth -= rasterRest; } //console.log('< ' + parentWidth + ' > ' + movingMax + ' = ' + movingWidth); if(movingWidth > 0){ jQuery('#listEntriesPreview_' + listId + ' ').animate({'margin-left' : '+=' + String(movingWidth)}); } }); jQuery('#list_' + listId + ' .listMoverForward').removeAttr('onclick').click(function(){ var parentWidth = jQuery('#listEntriesPreview_' + listId + ' ').parent().width(); var movingMax = jQuery('#listEntriesPreview_' + listId + ' ').width() - parentWidth + parseInt(jQuery('#listEntriesPreview_' + listId + ' ').css('margin-left')); var movingWidth = parentWidth > movingMax ? movingMax : parentWidth; var entryWidth = jQuery('#listEntriesPreview_' + listId + ' .listEntry').outerWidth(true); var rasterMod = parentWidth % entryWidth; var rasterRest = rasterMod; //console.log(entryWidth + ' ' + rasterMod); movingWidth -= rasterRest; //console.log('> ' + parentWidth + ' > ' + movingMax + ' = ' + movingWidth); if(movingWidth > 0){ jQuery('#listEntriesPreview_' + listId + ' ').animate({'margin-left' : '-=' + String(movingWidth)}); } }); } } function selectListEntryGallery(listId, position, options){ //console.log(listId + ', ' + position); options = options || {}; if(jQuery('#listEntries_' + listId).data('entryactive') == '1'){ return false; } var fadeTime = jQuery('#pictureGallery_' + listId).data('fadetime'); var animation = jQuery('#pictureGallery_' + listId).data('animation'); var animationDuration = jQuery('#pictureGallery_' + listId).data('animationduration'); var previewAnimation = jQuery('#pictureGallery_' + listId).data('previewanimation'); var numberEntries = jQuery('#pictureGallery_' + listId).data('numberentries'); var currentEntry = jQuery('#pictureGallery_' + listId).data('currententry'); var aspectRatio = jQuery('#pictureGallery_' + listId).data('aspectratio'); if(!aspectRatio || aspectRatio == ''){ aspectRatio = 1.333; } if(animation == 'carouselhorizontal'){ position = options['positionEntry'] || position; } if(position == '+'){ position = currentEntry < numberEntries ? parseInt(currentEntry) + 1 : 1; } else if(position == '-'){ position = currentEntry != 1 ? parseInt(currentEntry) - 1 : numberEntries; } else if(position == 'init'){ position = 1; } if(options['init'] != true && position == currentEntry){ return false; } if(jQuery('#containerGalleryFullSize').length > 0){ adaptGalleryFullSize(jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')')); } jQuery('#listEntries_' + listId + ' .listEntry').removeClass('listEntrySelected'); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').addClass('listEntrySelected'); if(typeof(fadeTime) != 'undefined' && fadeTime != '' && fadeTime != 0){ window.clearInterval(window.galleryObjects[listId]['interval']); window.galleryObjects[listId] = {'interval' : window.setInterval(function(){jQuery('#pictureGallery_' + listId).data('intervalcount', jQuery('#pictureGallery_' + listId).data('intervalcount') + 1);if(jQuery('#pictureGallery_' + listId).data('intervalcount') >= 128){window.clearInterval(window.galleryObjects[listId]['interval'])};selectListEntryGallery(listId, "+")}, fadeTime * 1000)}; } jQuery('#pictureGallery_' + listId).data('currententry', position); jQuery('#listEntries_' + listId).data('entryactive', 1); //console.log(animation); if(animation == 'slideFromRight'){ var slideWidth = jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry - 1) + ')').width(); var widthSlideCurrent = jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry - 1) + ')').innerWidth() var positionBefore = jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').css('position'); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').css({position: 'absolute', display: 'block', width: '100%', top: 0, left: String(slideWidth) + 'px'}); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry - 1) + ')').css({width: String(widthSlideCurrent) + 'px', display: 'block'}); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry - 1) + ')').animate({'marginLeft': '-=' + String(slideWidth)}, animationDuration, function(){ jQuery(this).css({marginLeft: 0, zIndex: 0}); }); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').animate({'left': '-=' + String(slideWidth)}, animationDuration, function(){ jQuery(this).css({display: 'block', position: positionBefore, marginLeft: 0, zIndex: 0}); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry - 1) + ')').hide(); jQuery('#listEntries_' + listId).data('entryactive', ''); }); } else if(animation == 'overlapFromRight'){ var slideWidth = jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry - 1) + ')').width(); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').css({position: 'absolute', display: 'block', width: '100%', top: 0, left: String(slideWidth) + 'px', zIndex: 1}); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').animate({'marginLeft': '-=' + String(slideWidth)}, animationDuration, function(){ jQuery(this).css({display: 'block', position: 'static', marginLeft: 0, zIndex: 0}); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry - 1) + ')').css({position: 'static', display: 'none'}); jQuery('#listEntries_' + listId).data('entryactive', ''); }); } else if(animation == 'overlapFromTop'){ var slideHeight = jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry - 1) + ')').height(); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').css({position: 'absolute', display: 'block', width: '100%', top: '-' + String(slideHeight) + 'px', left: 0, zIndex: 1}); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').animate({'top': '+=' + String(slideHeight)}, animationDuration, function(){ jQuery(this).css({display: 'block', position: 'static', marginLeft: 0, zIndex: 0}); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry - 1) + ')').css({position: 'static', display: 'none'}); jQuery('#listEntries_' + listId).data('entryactive', ''); }); } else if(animation == 'fadeIn'){ jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').css({position: 'absolute', display: 'block', width: '100%', top: 0, opacity: 0}); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').fadeTo(animationDuration, 1, function(){ jQuery(this).css({display: 'block', position: 'static'}); }); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry - 1) + ')').css({display: 'block', opacity: 1}).fadeTo(animationDuration, 0, function(){ jQuery(this).css({display: 'none', opacity: 1}); jQuery('#listEntries_' + listId).data('entryactive', ''); }); } else if(animation == 'moving'){ jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').css({position: 'absolute', display: 'block', width: '100%', top: 0, opacity: 0}); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').fadeTo(0, 1, function(){ jQuery(this).css({display: 'block', position: 'static'}); }); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry - 1) + ')').fadeTo(0, 0, function(){ jQuery(this).css({display: 'none', opacity: 1}); jQuery('#listEntries_' + listId).data('entryactive', ''); }); } else if(animation == 'zooming'){ jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').css({position: 'absolute', display: 'block', width: '100%', top: 0, opacity: 0}); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').fadeTo(0, 1, function(){ jQuery(this).css({display: 'block', position: 'static'}); }); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry - 1) + ')').fadeTo(0, 0, function(){ jQuery(this).css({display: 'none', opacity: 1}); jQuery('#listEntries_' + listId).data('entryactive', ''); }); } else if(animation == 'collage'){ jQuery('#listEntries_' + listId).data('numberChanged', jQuery('#listEntries_' + listId).data('numberChanged') ? jQuery('#listEntries_' + listId).data('numberChanged') + 1 : 1); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').css({'transform': 'rotate(0deg)'}); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry - 1) + ')').css({'z-index' : (1000 - jQuery('#listEntries_' + listId).data('numberChanged')), 'transform': 'rotate(' + parseInt(Math.random() * 30 - 15) + 'deg)'}); jQuery('#listEntries_' + listId).data('entryactive', ''); } else if(animation == 'carouselhorizontal'){ var widthElement = jQuery('#listEntries_' + listId).width(); var heightElement = jQuery('#listEntries_' + listId).parent().get(0).offsetHeight; position = options['positionEntry'] || position; diffPosition = position - currentEntry; if(diffPosition > 0){ for(i = 0; i < diffPosition; i++){ jQuery('#listEntries_' + listId).append(jQuery('#listEntries_' + listId + ' .listEntry:first')); } } else if(diffPosition < 0){ for(i = 0; i < -diffPosition; i++){ jQuery('#listEntries_' + listId).prepend(jQuery('#listEntries_' + listId + ' .listEntry:last')); } } position = currentEntry; jQuery('#pictureGallery_' + listId).data('currententry', position); jQuery('#listEntries_' + listId + ' .listEntry').each(function(index){ jQuery(this).find('.listEntryButtons').remove(); index ++; var diff = position - index > 0 ? position - index : index - position; var raster = 1 / (numberEntries); var widthRel = jQuery(this).data('width-entry-rel'); var scale = widthRel * (1 / (1 + diff * widthRel)); var entryWidth = scale * 100; var entryLeft = 50; var entryLeftDiff = (50 - 50 / (diff * 2)); var entryBottom = (heightElement - ((widthElement * entryWidth / 100) / aspectRatio)) / 2; if(!jQuery(this).data('displaytitle')){ if(jQuery(this).find('.listEntryTitle').css('display') == 'none'){ jQuery(this).data('displaytitle', 'none'); } else{ jQuery(this).data('displaytitle', 'block'); } } if(index - position < 0){ entryLeft = entryLeft - entryLeftDiff; jQuery(this).find('.listEntryTitle').css({'display': 'none'}); } else if(index - position > 0){ entryLeft = entryLeft + entryLeftDiff; jQuery(this).find('.listEntryTitle').css({'display': 'none'}); } else{ entryLeft = entryLeft; if(jQuery(this).data('displaytitle') != 'none'){ jQuery(this).find('.listEntryTitle').css({'display': 'block'}); } } entryLeftStyle = String(widthElement * entryLeft / 100) + 'px'; entryBottomStyle = String(entryBottom) + 'px'; entryMarginStyle = '-' + String(widthElement * (entryWidth / 2) / 100) + 'px'; jQuery(this).css({'z-index': numberEntries - diff}); if(entryWidth < 3){ jQuery(this).css({'display': 'none'}); } else{ jQuery(this).css({'display': 'block'}); if(options['init']){ jQuery(this).css({'bottom' : entryBottomStyle, 'width': String(entryWidth) + '%', 'margin-left': entryMarginStyle, 'left': entryLeftStyle}); } else{ jQuery(this).animate({'bottom' : entryBottomStyle, 'width': String(entryWidth) + '%', 'margin-left': entryMarginStyle, 'left': entryLeftStyle}, {queue: false, duration: animationDuration}); } } jQuery('#listEntries_' + listId).data('entryactive', ''); }); } else{ jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').css({position: 'absolute', display: 'block', width: '100%', top: 0, opacity: 0}); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').fadeTo(0, 1, function(){ jQuery(this).css({display: 'block', position: 'static'}); }); jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry - 1) + ')').fadeTo(0, 0, function(){ jQuery(this).css({display: 'none', opacity: 1}); jQuery('#listEntries_' + listId).data('entryactive', ''); }); } selectListEntryGalleryPreview(listId, position); onAfterSelectListEntryGallery(listId, position - 1); } function selectListEntryGalleryPreview(listId, position){ var fadeTime = jQuery('#pictureGallery_' + listId).data('fadetime'); var animation = jQuery('#pictureGallery_' + listId).data('previewanimation'); var animationDuration = jQuery('#pictureGallery_' + listId).data('animationduration'); var numberEntries = jQuery('#pictureGallery_' + listId).data('numberentries'); var currentEntry = jQuery('#pictureGallery_' + listId).data('currententry'); jQuery('#listEntriesPreview_' + listId + ' .listEntry').removeClass('listEntrySelected'); jQuery('#listEntriesPreview_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').addClass('listEntrySelected'); if(fadeTime != ''){ jQuery('#listEntriesPreview_' + listId + ' .listEntry').removeClass('listEntryProgress'); jQuery('#listEntriesPreview_' + listId + ' .listEntry:eq(' + String(position - 1) + ')').addClass('listEntryProgress'); } if(animation == 'slidehorizontal'){ var widthContainerPreviewEntry = jQuery('#listEntriesPreview_' + listId).parent().width(); var widthOuterPreviewEntry = jQuery('#listEntriesPreview_' + listId + ' .listEntry').first().outerWidth() + parseInt(jQuery('#listEntriesPreview_' + listId + ' .listEntry').first().css('margin-right')); var numberEntriesVisible = parseInt(widthContainerPreviewEntry / widthOuterPreviewEntry); var marginLeft = (position - 1 - Math.round(numberEntriesVisible / 2)) * (widthOuterPreviewEntry); if(marginLeft < 0){ marginLeft = 0; } jQuery('#listEntriesPreview_' + listId).animate('listEntrySelected').animate({'marginLeft': '-' + String(marginLeft) + 'px'}, animationDuration); } else if(animation == 'slidevertical'){ var heightContainerPreviewEntry = jQuery('#listEntriesPreview_' + listId).parent().height(); var heightOuterPreviewEntry = jQuery('#listEntriesPreview_' + listId + ' .listEntry').first().outerHeight() + parseInt(jQuery('#listEntriesPreview_' + listId + ' .listEntry').first().css('margin-bottom')); var numberEntriesVisible = parseInt(heightContainerPreviewEntry / heightOuterPreviewEntry); var marginTop = (position - 1 - Math.round(numberEntriesVisible / 2)) * (heightOuterPreviewEntry); if(marginTop < 0){ marginTop = 0; } jQuery('#listEntriesPreview_' + listId).animate('listEntrySelected').animate({'marginTop': '-' + String(marginTop) + 'px'}, animationDuration); } else if(animation == 'carouselhorizontal'){ var widthContainerPreviewEntry = jQuery('#listEntriesPreview_' + listId).parent().width(); var widthOuterPreviewEntry = jQuery('#listEntriesPreview_' + listId + ' .listEntry').first().outerWidth() + parseInt(jQuery('#listEntriesPreview_' + listId + ' .listEntry').first().css('margin-right')); var numberEntriesVisible = parseInt(widthContainerPreviewEntry / widthOuterPreviewEntry); var marginLeft = (position - 1 - Math.round(numberEntriesVisible / 2)) * (widthOuterPreviewEntry); if(marginLeft < 0){ marginLeft = 0; } jQuery('#listEntriesPreview_' + listId).animate('listEntrySelected').animate({'marginLeft': '-' + String(marginLeft) + 'px'}, animationDuration); jQuery('#listEntriesPreview_' + listId + ' .listEntrySelected .listEntryImage').animate('listEntrySelected').animate({'height': String(60) + 'px'}, animationDuration); } } function onAfterSelectListEntryGallery(listId, currentEntry){ var fadeTime = jQuery('#pictureGallery_' + listId).data('fadetime'); var animation = jQuery('#pictureGallery_' + listId).data('animation'); var animationZoom = jQuery('#pictureGallery_' + listId).data('animationzoom'); var animationDuration = jQuery('#pictureGallery_' + listId).data('animationduration'); var previewAnimation = jQuery('#pictureGallery_' + listId).data('previewanimation'); var numberEntries = jQuery('#pictureGallery_' + listId).data('numberentries'); //console.log(currentEntry); jQuery('#pictureGallery_' + listId + ' .listEntryOfEntriesEntry').html(currentEntry + 1); if(animation == 'moving'){ jQuery.each(jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry) + ')'), function(){ var movingDuration = fadeTime * 1000; var movingWidth = jQuery(this).find('.listEntryImage').width() - jQuery(this).parent().width(); var movingHeight = jQuery(this).find('.listEntryImage').height() - jQuery(this).parent().height(); var directionHori = Math.random() > 0.5 ? 'right' : 'left'; var directionVert = Math.random() > 0.5 ? 'bottom' : 'top'; if(jQuery(this).parent().attr('data-movingDirectionHori')){ var directionToChange = Math.random() > 0.5 ? 'hori' : 'vert'; //console.log('directionToChange:' + directionToChange); if(directionToChange == 'hori'){ if(jQuery(this).parent().attr('data-movingDirectionHori') == 'right'){ directionHori = 'left'; } else{ directionHori = 'right'; } directionVerti = jQuery(this).parent().attr('data-movingDirectionVert'); } else{ if(jQuery(this).parent().attr('data-movingDirectionVert') == 'bottom'){ directionVert = 'top'; } else{ directionVert = 'bottom'; } directionHori = jQuery(this).parent().attr('data-movingDirectionHori'); } } //console.log(directionHori + ' / ' + directionVert); jQuery('#listEntries_' + listId).attr('data-movingDirectionHori', directionHori); jQuery('#listEntries_' + listId).attr('data-movingDirectionVert', directionVert); jQuery(this).find('.listEntryImage').css({'marginLeft' : 0, 'marginTop' : 0}); if(directionHori == 'right'){ jQuery(this).find('.listEntryImage').css({'marginLeft' : -movingWidth}); } if(directionVert == 'bottom'){ jQuery(this).find('.listEntryImage').css({'marginTop' : -movingHeight}); } //console.log(directionHori + '/' + directionVert); if(movingWidth > 0){ jQuery(this).find('.listEntryImage').animate({'marginLeft': (directionHori == 'right' ? '+=' : '-=') + movingWidth}, {duration: movingDuration, easing: "linear" , queue: false}); } if(movingHeight > 0){ jQuery(this).find('.listEntryImage').animate({'marginTop': (directionVert == 'bottom' ? '+=' : '-=') + movingHeight}, {duration: movingDuration, easing: "linear" , queue: false}); } }); } else if(animation == 'zooming'){ jQuery.each(jQuery('#listEntries_' + listId + ' .listEntry:eq(' + String(currentEntry) + ')'), function(){ var movingDuration = fadeTime * 1000; var widthOuter = jQuery(this).parent().width(); var heightOuter = jQuery(this).parent().height(); var widthImage = jQuery(this).find('.listEntryImage').width(); var heightImage = jQuery(this).find('.listEntryImage').height(); var diffWidth = widthImage - widthOuter; var diffHeight = heightImage - heightOuter; var ratioOuter = widthOuter / heightOuter; var ratioImage = widthImage / heightImage; var widthImageStart = widthOuter; var heightImageStart = widthOuter / ratioImage; var widthImageEnd = widthImageStart; var heightImageEnd = heightImageStart; var marginLeftStart = 0; var marginTopStart = 0; var marginLeftEnd = 0; var marginTopEnd = 0; //console.log('...'); //console.log(widthOuter + ' / ' + heightOuter); //console.log(widthImage + ' / ' + heightImage); //console.log(diffWidth + ' / ' + diffHeight); //console.log(ratioImage + ' : ' + ratioOuter); if(heightImageStart < heightOuter){ widthImageStart = widthImageStart * heightOuter / heightImageStart; heightImageStart = heightOuter; } if(widthImageStart > widthOuter){ marginLeftStart = (widthOuter - widthImageStart) / 2; } if(heightImageStart > heightOuter){ marginTopStart = (heightOuter - heightImageStart) / 2; } widthImageEnd = widthImageStart * (typeof(animationZoom) == 'number' ? parseFloat(animationZoom) : 1.5); heightImageEnd = widthImageEnd / ratioImage; marginLeftEnd = marginLeftStart - (widthImageEnd - widthImageStart) / 2; marginTopEnd = marginTopStart - (heightImageEnd - heightImageStart) / 2 jQuery(this).find('.listEntryImage').css({'margin-left' : marginLeftStart, 'margin-top' : marginTopStart, 'width' : String(widthImageStart) + 'px', 'height' : 'auto'}); jQuery(this).find('.listEntryImage').animate({'margin-left': marginLeftEnd, 'margin-top': marginTopEnd, 'width': widthImageEnd}, {duration: movingDuration, easing: "linear" , queue: false}); }); } } function expandGalleryToFullSize(element, event){ if(element.className.indexOf('listEntriesPreview') != -1){ element = element.parentNode.parentNode; } if(jQuery('#containerGalleryFullSize').length == 0){ jQuery('body').prepend('
'); jQuery('#containerGalleryFullSize').data('elementtorestoreid', element.id); adaptGalleryFullSize(); jQuery(element).prependTo('#containerGalleryFullSize'); jQuery('#containerGalleryFullSize').prepend(''); jQuery('#containerGalleryFullSizeCloser').click(restoreGalleryFromFullSize); jQuery(window).bind('resize', restoreGalleryFromFullSize); jQuery(window).keydown(function(event){ if(event.which == 27){ restoreGalleryFromFullSize(); } }); } } function adaptGalleryFullSize(elementToAdapt){ if(jQuery('#containerGalleryFullSize').length > 0){ element = jQuery('#' + jQuery('#containerGalleryFullSize').data('elementtorestoreid')).get(0); var widthImageDetail = jQuery(element).find('.listEntrySelected img.listEntryImage').width(); var maxWidthFullsize = jQuery(element).attr('data-maxwidthfullsize'); var srcOriginal = jQuery(element).find('.listEntrySelected').attr('data-src'); var elementRatio = jQuery(element).find('.listEntrySelected img.listEntryImage').width() / jQuery(element).find('.listEntrySelected img.listEntryImage').height(); var viewportRatio = jQuery(window).width() / jQuery(window).height(); var widthFull = jQuery(window).width(); var heightFull = jQuery(window).height(); var leftFull = 0; var topFull = 0; if(!elementToAdapt){ if(jQuery(element).length == 0){ return false; } elementToAdapt = jQuery(element).find('.listEntrySelected'); } var srcOriginal = elementToAdapt.attr('data-src'); if(srcOriginal){ var widthImageDetail = elementToAdapt.find('img.listEntryImage').attr('width'); var heightImageDetail = elementToAdapt.find('img.listEntryImage').attr('height'); var imageRatio = widthImageDetail / heightImageDetail; var raster = 256; var widthImage = widthFull + (widthFull % raster == 0 ? 0 : - widthFull % raster + raster); var heightImage = heightFull + (heightFull % raster == 0 ? 0 : - heightFull % raster + raster); if(maxWidthFullsize && /^(\d+)(px)?$/.test(maxWidthFullsize)){ maxWidthFullsize = RegExp.$1; if(maxWidthFullsize < widthImage){ widthImage = maxWidthFullsize; heightImage = widthImage / imageRatio; } } if(typeof(elementToAdapt.find('img.listEntryImage').first().attr('data-src-orig')) == 'undefined'){ elementToAdapt.find('img.listEntryImage').first().attr('data-src-orig', elementToAdapt.find('img.listEntryImage').first().attr('src')); } elementToAdapt.find('img.listEntryImage').first().hide().css({'min-width' : '100%', 'min-height' : '100%', 'width' : 'auto', 'height' : 'auto'}); elementToAdapt.find('img.listEntryImage').first().bind('load', function(){jQuery(this).fadeIn(500)}); window.setTimeout(function(){ elementToAdapt.find('img.listEntryImage').first().removeAttr('data-src2x').attr('src', '/weblication/grid5/scripts/wImage.php?mode=crop&action=showImageSize&path=' + srcOriginal + '&width=' + widthImage + '&height=' + heightImage); }, 10); jQuery('#containerGalleryFullSize').css({'width': widthFull, 'height': heightFull, 'left': leftFull, 'top': topFull}); } else{ if(elementRatio > viewportRatio){ widthFull = heightFull * elementRatio; leftFull = - ((widthFull - jQuery(window).width()) / 2); } else if(elementRatio < viewportRatio){ heightFull = widthFull / elementRatio; topFull = - ((heightFull - jQuery(window).height()) / 2); } if(!elementToAdapt){ if(jQuery(element).length == 0){ return false; } elementToAdapt = jQuery(element).find('.listEntrySelected'); } jQuery('#containerGalleryFullSize').css({'width': widthFull, 'height': heightFull, 'left': leftFull, 'top': topFull}); } } } function restoreGalleryFromFullSize(event){ if(jQuery('#containerGalleryFullSize').length > 0){ var listId = jQuery('#containerGalleryFullSize').data('elementtorestoreid').replace(/pictureGallery_/, 'list_'); jQuery('#containerGalleryFullSize').find('#' + jQuery('#containerGalleryFullSize').data('elementtorestoreid')).appendTo('#' + listId); jQuery('#containerGalleryFullSize').remove(); jQuery('#' + listId + ' .listEntries img.listEntryImage').each(function(){ jQuery(this).css({'min-width' : '0', 'min-height' : '0', 'width' : '', 'height' : ''}); if(typeof(jQuery(this).attr('data-src-orig')) != 'undefined'){ (function(currentElement){ window.setTimeout(function(){ currentElement.attr('src', currentElement.attr('data-src-orig')); }, 10); })(jQuery(this)); } }); } }