');this.$galleryNavBtnLeft=$(MerlinGalleryUtils.navBtnLeft).addClass('fa-2x').css('left','6px');this.$galleryNavBtnRight=$(MerlinGalleryUtils.navBtnRight).addClass('fa-2x').css('right','6px');this.$bottomGalleryContainer=$('
');this.thumbWidth=160;this.thumbMargin=8;this.totalThumbWidth=this.thumbWidth+this.thumbMargin;this.uid=Math.floor(Math.random()*26)+Date.now();this.$closeBtn=$('
');this.$fsContainer=$('
').attr('data-id',this.uid);this.$fsNavBtnLeft=$(MerlinGalleryUtils.btnWrapper).addClass('pull-left').append($(MerlinGalleryUtils.navBtnLeft).addClass('fa-3x').css('left','15px'));this.$fsNavBtnRight=$(MerlinGalleryUtils.btnWrapper).addClass('pull-right').append($(MerlinGalleryUtils.navBtnRight).addClass('fa-3x').css('right','15px'));this.keyDownHandlerFunction=this.keyDownHandler.bind(this);this.$galleryContainer=$galleryElement;this.targetElement=targetElement;this.$eventTarget=$eventTarget;this.$galleryImageContainer.append(this.$galleryImage);this.$bottomGalleryContainer.append(this.$galleryNavBtnLeft.addClass('disabled'),this.$galleryNavBtnRight,this.$galleryScrollPane.append(this.$galleryContent));this.$galleryContainer.append(this.$bottomGalleryContainer);this.$galleryContainer.before(this.$spinner,this.$galleryImageContainer).show().parent().addClass('merlin-gallery-container');this.$fsContainer.append(this.$closeBtn,this.$galleryContainer.parent(),this.$fsNavBtnLeft,this.$fsNavBtnRight);}
GalleryFullscreenContentGallery.prototype.loadGallery=function(imgList,titlesArray){var _this_1=this;this.titles=titlesArray;clearTimeout(this.spinnerTimeout);this.spinnerTimeout=setTimeout(function(){_this_1.$galleryImageContainer.append(_this_1.$spinner);},200);var $allElements=$();$.each(imgList,function(index,element){var title="".concat(titlesArray[index]);$allElements=$allElements.add('

');});this.galleryViewWidth=this.$galleryContent.width();this.$lastGalleryImage=$allElements.eq(this.targetElement).addClass('active');this.$galleryContent.empty().append($allElements);this.galleryLength=imgList.length*170;this.$tmpImage.attr('src',$allElements[this.targetElement]['src']);if(this.galleryLength-this.galleryViewWidth>0)
this.$galleryNavBtnLeft.add(this.$galleryNavBtnRight).show();this.$galleryImageContainer.attr('data-index',this.targetElement);this.previewList=imgList;this.thumbnailsList=imgList;this.showFullscreen();this.addGalleryListeners();this.$tmpImage.unbind('load').load(function(){clearTimeout(_this_1.spinnerTimeout);var title=titlesArray[_this_1.targetElement];_this_1.$spinner.detach();_this_1.$galleryImageContainer.append(_this_1.$tmpImage);if(!_this_1.$galleryImageContainer.find('.img-title').length){_this_1.$galleryImageContainer.prepend("
".concat(title,"
"));}
_this_1.$galleryImage=_this_1.$tmpImage;_this_1.lastFsImageWidth=_this_1.$tmpImage.width();_this_1.lastFsImageHeight=_this_1.$tmpImage.height();});};GalleryFullscreenContentGallery.prototype.showFullscreen=function(){var _this_1=this;$(window).on('keydown',this.keyDownHandlerFunction);$('body').append(this.$fsContainer).css('overflow','hidden');this.$fsContainer.on(MerlinGalleryUtils.pointerEventType,function(e,oldEvent){if(oldEvent){oldEvent.stopPropagation();oldEvent.preventDefault();}
if($(e.target).is('.btn-gallery-close')){_this_1.hideGallery();}
if($(e.target).closest('.bottom-gallery-container').length||$(e.target).closest('.mg-btn-container').length||$(e.target).closest('.mg-fs-image-container').length){e.preventDefault();e.stopPropagation();}
else{_this_1.hideGallery();}});this.checkButtonsState(true);this.$fsNavBtnLeft.on(MerlinGalleryUtils.pointerEventType,this.prevImage.bind(this));this.$fsNavBtnRight.on(MerlinGalleryUtils.pointerEventType,this.nextImage.bind(this));this.$galleryImageContainer.on(MerlinGalleryUtils.pointerEventType,this.nextImage.bind(this));this.swipeSupport();};GalleryFullscreenContentGallery.prototype.swipeSupport=function(){var _this_1=this;this.$galleryImageContainer.on('touchstart touchmove touchend',function(e){e.preventDefault();}).on('swipe',function(e){if(e['direction']==='left'){_this_1.nextImage(null,null);}
else if(e['direction']==='right'){_this_1.prevImage(null,null);}});this.$galleryContainer.on('touchstart touchmove touchend',function(e){e.preventDefault();}).on('swipe',function(e){if(e['direction']==='left'){_this_1.scrollGallery(false,null);}
else if(e['direction']==='right'){_this_1.scrollGallery(true,null);}});};GalleryFullscreenContentGallery.prototype.checkButtonsState=function(onLoad){var _this_1=this;if(onLoad===void 0){onLoad=false;}
var imagesOnScreen=Math.floor(this.$galleryContent.width()/this.totalThumbWidth);var displacement=imagesOnScreen*this.totalThumbWidth;var activeFromLeft=this.$galleryContainer.find('img.active').offset();if(activeFromLeft){var tmp=activeFromLeft.left;if(tmp>displacement){onLoad?this.scrollGallery(false,tmp):this.scrollGallery(false,null);}
else if(tmp<0){onLoad?this.scrollGallery(true,tmp):this.scrollGallery(true,null);}
setTimeout(function(){var index=parseInt(_this_1.$galleryImageContainer.attr('data-index'));if(!index||index<=0){_this_1.$fsNavBtnLeft.children().addClass('disabled');}
else if(_this_1.$fsNavBtnLeft.children().hasClass('disabled')){_this_1.$fsNavBtnLeft.children().removeClass('disabled');}
var galleryLength=_this_1.$galleryContent.find('img').length;if(index>=galleryLength-1){_this_1.$fsNavBtnRight.children().addClass('disabled');}
else if(_this_1.$fsNavBtnRight.children().hasClass('disabled')){_this_1.$fsNavBtnRight.children().removeClass('disabled');}},200);}};GalleryFullscreenContentGallery.prototype.nextImage=function(e,oldEvent){var index=parseInt(this.$galleryImageContainer.attr('data-index'));if(!index)
index=0;var galleryLength=this.$galleryContent.find('img').length;if(index>=galleryLength-1)
return;var title=this.titles[index+1];if(title){$(this.$galleryImageContainer).find('.img-title').text(title);}
else{$(this.$galleryImageContainer).find('.img-title').text('');}
if(oldEvent){oldEvent.stopPropagation();oldEvent.preventDefault();}
if(e){e.preventDefault();e.stopPropagation();}
if(this.$lastGalleryImage)
this.$lastGalleryImage.removeClass('active');var that=this;this.$galleryImageContainer.fadeOut(150,function(){that.$galleryImageContainer.fadeIn(150);that.$galleryImage.attr('src',that.previewList[index+1]).parent().attr('data-index',index+1);});this.$lastGalleryImage=this.$galleryScrollPane.find('img').eq(index+1).addClass('active');this.checkButtonsState();};GalleryFullscreenContentGallery.prototype.prevImage=function(e,oldEvent){var index=parseInt(this.$galleryImageContainer.attr('data-index'));if(!index||index<=0)
return;var title=this.titles[index-1];if(title){$(this.$galleryImageContainer).find('.img-title').text(title);}
else{$(this.$galleryImageContainer).find('.img-title').text('');}
if(oldEvent){oldEvent.stopPropagation();oldEvent.preventDefault();}
if(e){e.preventDefault();e.stopPropagation();}
if(this.$lastGalleryImage){this.$lastGalleryImage.removeClass('active');}
var that=this;this.$galleryImageContainer.fadeOut(150,function(){that.$galleryImageContainer.fadeIn(150);that.$galleryImage.attr('src',that.previewList[index-1]).parent().attr('data-index',index-1);});this.$lastGalleryImage=this.$galleryScrollPane.find('img').eq(index-1).addClass('active');this.checkButtonsState();};GalleryFullscreenContentGallery.prototype.hideGallery=function(){this.$fsContainer.detach();this.$galleryImageContainer.remove();$('body').css('overflow','');};GalleryFullscreenContentGallery.prototype.addGalleryListeners=function(){var _this_1=this;this.$galleryContainer.on(MerlinGalleryUtils.pointerEventType,'img',function(e,oldEvent){var index=_this_1.thumbnailsList.indexOf($(e.target).attr('src'));var title=$(e.target).attr('data-title');if(title){$(_this_1.$galleryImageContainer).find('.img-title').text(title);}
if(oldEvent){oldEvent.stopPropagation();oldEvent.preventDefault();}
if(_this_1.$lastGalleryImage)
_this_1.$lastGalleryImage.removeClass('active');var that=_this_1;_this_1.$galleryImageContainer.fadeOut(150,function(){that.$galleryImageContainer.fadeIn(150);that.$galleryImage.attr('src',that.previewList[index]).parent().attr('data-index',index);});_this_1.$lastGalleryImage=$(e.target).addClass('active');_this_1.checkButtonsState();}).on(MerlinGalleryUtils.pointerEventType,'.gallery-button',function(e,oldEvent){if(oldEvent){oldEvent.stopPropagation();oldEvent.preventDefault();}
if(_this_1.$galleryScrollPane.is(':animated'))
return;var $target=$(e.target);if(!$target.is('.gallery-button'))
$target=$target.closest('.gallery-button');_this_1.scrollGallery($target.find('i').is('.fa-angle-left'),null);});if(MerlinGalleryUtils.hasOwnProperty('pointerEventType')&&this.$eventTarget){this.$eventTarget.on(MerlinGalleryUtils.pointerEventType,function(e){if(_this_1.targetElement){$('.gallery-content').find('img').eq($(e.target).parent().index()).trigger('click');}
$('[data-id="'+_this_1.uid+'"]').show();$('body').css('overflow','hidden');_this_1.checkButtonsState(true);});}
if(MerlinGalleryUtils.pointerEventType=='tap'){this.$galleryContainer.on('touchstart touchmove touchend',function(e){e.preventDefault();}).on('swipe',function(e){if(e['direction']==='left'){_this_1.scrollGallery(false,null);}
else if(e['direction']==='right'){_this_1.scrollGallery(true,null);}});}};GalleryFullscreenContentGallery.prototype.scrollGallery=function(scrollLeft,elemLeftOffset){var imagesOnScreen=Math.floor(this.$galleryContent.width()/this.totalThumbWidth);var displacement=imagesOnScreen*this.totalThumbWidth;this.galleryViewWidth=this.$galleryContent.width()-this.totalThumbWidth;if(scrollLeft){if(this.$galleryNavBtnRight.is('.disabled'))
displacement-=this.$galleryScrollPane.width()-imagesOnScreen*this.totalThumbWidth+this.thumbMargin;if(this.$galleryScrollPane.scrollLeft()-this.galleryViewWidth<=this.totalThumbWidth)
this.$galleryNavBtnLeft.addClass('disabled');this.$galleryNavBtnRight.removeClass('disabled');if(elemLeftOffset){this.$galleryScrollPane.animate({scrollLeft:elemLeftOffset+this.$galleryScrollPane.scrollLeft()+window.innerWidth/2-displacement},{duration:300,queue:false});return;}
this.$galleryScrollPane.animate({scrollLeft:this.$galleryScrollPane.scrollLeft()-displacement},{duration:300,queue:false});}
else{if(this.$galleryScrollPane.scrollLeft()+displacement>=this.galleryLength-displacement-this.totalThumbWidth)
this.$galleryNavBtnRight.addClass('disabled');this.$galleryNavBtnLeft.removeClass('disabled');if(elemLeftOffset){this.$galleryScrollPane.animate({scrollLeft:elemLeftOffset+this.$galleryScrollPane.scrollLeft()+window.innerWidth/2-displacement},{duration:300,queue:false});return;}
this.$galleryScrollPane.animate({scrollLeft:this.$galleryScrollPane.scrollLeft()+displacement},{duration:300,queue:false});}};GalleryFullscreenContentGallery.prototype.keyDownHandler=function(e){if(this.$fsContainer.is(':hidden'))
return;var key=e.which;if(key==37){this.prevImage(null,null);}
else if(key==39){this.nextImage(null,null);}
else if(key==27){this.hideGallery();}};return GalleryFullscreenContentGallery;}());var MerlinGalleryUtils=(function(){function MerlinGalleryUtils(){}
MerlinGalleryUtils.btnWrapper='
';MerlinGalleryUtils.navBtnLeft='
';MerlinGalleryUtils.navBtnRight='
';MerlinGalleryUtils.spinner='
';MerlinGalleryUtils.zoomInBtn='';MerlinGalleryUtils.pointerEventType=((window.navigator.msMaxTouchPoints||'ontouchstart'in window)?'tap click':'click');return MerlinGalleryUtils;}());