var MerlinFullscreenGallery=(function(){function MerlinFullscreenGallery($initElementsContainer,imageList,onTopOf){if(onTopOf===void 0){onTopOf=null;} var _this_1=this;this.$spinner=$(MerlinGalleryUtils.spinner);this.$closeBtn=$('');this.uid=Math.floor(Math.random()*26)+Date.now();this.$fsContainer=$('').attr('data-id',this.uid);this.$fsimageContainer=$('
');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.merlinGallery=null;this.keyDownHandlerFunction=this.keyDownHandler.bind(this);var triggerElementClass='.mg-image-container';this.$fsInitElementContainer=$initElementsContainer;this.imageList=imageList;this.$fsContainer.append(this.$fsNavBtnLeft,this.$fsNavBtnRight,this.$closeBtn,this.$fsimageContainer);var _this=this;if($initElementsContainer.is('.mg-image-container')){triggerElementClass='';$initElementsContainer.prepend(MerlinGalleryUtils.zoomInBtn).css('cursor','pointer');} else $initElementsContainer.find('img').css('cursor','pointer').before(MerlinGalleryUtils.zoomInBtn);if(onTopOf){var zIndexes=[];$.each(onTopOf,function(index,element){var $index=Number($(element).css('z-index'));if($index>0){zIndexes.push($index);} else{zIndexes.push(element.style.zIndex);}});zIndexes.sort(function(a,b){return a-b;});this.$fsContainer.css('z-index',(zIndexes[0]+2));} $initElementsContainer.on(MerlinGalleryUtils.pointerEventType,triggerElementClass,function(e,oldEvent){if(oldEvent){oldEvent.stopPropagation();oldEvent.preventDefault();} var $clickedElement=$(e.target);var $element=$(e.currentTarget).closest('.object-listing-elem');var htlCode=$element.attr('data-ofr_id');var htlTourop=$element.attr('data-ofr_tourOp');var title=$element.find('.offer-title').html();if(!$clickedElement.is('.mg-image-container')) $clickedElement=$clickedElement.closest('.mg-image-container');var selectedImage=$clickedElement.attr('data-index');if($clickedElement.closest('.booking').length>0){if(null===_this_1.merlinGallery){_this_1.merlinGallery=new MerlinQtipGallery();} _this_1.merlinGallery.additionalDataQtip(title,htlCode,htlTourop,'gallery',selectedImage);} else{_this_1.showFullscreen($clickedElement.attr('data-index'));}});if(MerlinGalleryUtils.pointerEventType!='tap'){$initElementsContainer.on('mouseover',triggerElementClass,function(e){$(this).find('.btn-zoom-in').show();}).on('mouseout',triggerElementClass,function(e){$(this).find('.btn-zoom-in').hide();});} else{this.$fsContainer.on('touchstart touchmove touchend',function(e){e.preventDefault();}).on('swipe',function(e){if(e['direction']==='left'){_this_1.prevImage(e,null);} else if(e['direction']==='right'){_this_1.nextImage(e,null);}});}} MerlinFullscreenGallery.prototype.cleanUp=function(){this.$fsInitElementContainer.off();this.$fsContainer.off();};MerlinFullscreenGallery.prototype.showFullscreen=function(galleryIndex){var _this_1=this;$(window).on('keydown',this.keyDownHandlerFunction);this.lastFsImageIndex=Number(galleryIndex);$('body').append(this.$fsContainer).css('overflow','hidden');this.loadImage();this.$fsContainer.on(MerlinGalleryUtils.pointerEventType,function(e,oldEvent){if(oldEvent){oldEvent.stopPropagation();oldEvent.preventDefault();} if($(e.target).is('.btn-gallery-close')){_this_1.hideGallery();_this_1.$fsContainer.off(MerlinGalleryUtils.pointerEventType);_this_1.$lastFsImage=undefined;} if($(e.target).closest('.gallery-fs-image-container').length){e.preventDefault();e.stopPropagation();} else{_this_1.hideGallery();_this_1.$fsContainer.off(MerlinGalleryUtils.pointerEventType);_this_1.$lastFsImage=undefined;}});this.$fsNavBtnLeft.on(MerlinGalleryUtils.pointerEventType,this.prevImage.bind(this));this.$fsNavBtnRight.on(MerlinGalleryUtils.pointerEventType,this.nextImage.bind(this));};MerlinFullscreenGallery.prototype.nextImage=function(e,oldEvent){if(oldEvent){oldEvent.stopPropagation();oldEvent.preventDefault();} if(e){e.preventDefault();e.stopPropagation();} this.lastFsImageIndex++;if(this.lastFsImageIndex==this.imageList.length) this.lastFsImageIndex=0;this.loadImage();};MerlinFullscreenGallery.prototype.prevImage=function(e,oldEvent){if(oldEvent){oldEvent.stopPropagation();oldEvent.preventDefault();} if(e){e.preventDefault();e.stopPropagation();} this.lastFsImageIndex--;if(this.lastFsImageIndex==-1) this.lastFsImageIndex=this.imageList.length-1;this.loadImage();};MerlinFullscreenGallery.prototype.hideGallery=function(){if(this.$lastFsImage) this.$lastFsImage.remove();this.$fsContainer.detach();$('body').css('overflow','');this.$fsNavBtnLeft.off(MerlinGalleryUtils.pointerEventType);this.$fsNavBtnRight.off(MerlinGalleryUtils.pointerEventType);$(window).off('keydown',this.keyDownHandlerFunction);};MerlinFullscreenGallery.prototype.loadImage=function(){var _this_1=this;if(this.$lastFsImage) this.$lastFsImage.attr('src','');this.$tempImage=$('');clearTimeout(this.spinnerTimeout);this.spinnerTimeout=setTimeout(function(){_this_1.$fsimageContainer.append(_this_1.$spinner);},200);this.$tempImage.unbind('load').load(function(){clearTimeout(_this_1.spinnerTimeout);if(_this_1.$lastFsImage) _this_1.$lastFsImage.remove();_this_1.$spinner.detach();_this_1.$fsimageContainer.append(_this_1.$tempImage);_this_1.$lastFsImage=_this_1.$tempImage;_this_1.lastFsImageWidth=_this_1.$lastFsImage.width();_this_1.lastFsImageHeight=_this_1.$lastFsImage.height();});};MerlinFullscreenGallery.prototype.keyDownHandler=function(e){e.preventDefault();e.stopPropagation();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 MerlinFullscreenGallery;}());var MerlinContentGallery=(function(){function MerlinContentGallery($galleryElement,hasFullscreen,hasNavBtns){if(hasFullscreen===void 0){hasFullscreen=false;} if(hasNavBtns===void 0){hasNavBtns=false;} this.$spinner=$(MerlinGalleryUtils.spinner);this.$galleryImageContainer=$('
');this.$galleryImage=$('');this.$galleryScrollPane=$('