$(function(){fitScreen();for(let i in _hotspots){let potsData=_hotspots[i];let delayT=Math.random()*0.5;TweenMax.fromTo("#buoy-item-"+i,0.6,{y:-2000},{y:-15,ease:Back.easeOut.config(0.3),delay:delayT})}});let mapScale=1;let mapMinWidth=600;let mapMinHeight=500;let mapContainerWidth=0;let mapContainerHeight=0;let headerHeight=60;let fitScreen=function(){let bgWidth=2003;let bgHeight=1256;let bgZoom=1;let bgVH=0;let bgVW=0;let bgVLeft=0;let bgVTop=0;mapContainerWidth=(innerWidth>mapMinWidth)?innerWidth:mapMinWidth;mapContainerHeight=(innerHeight-headerHeight>mapMinHeight)?(innerHeight-headerHeight):mapMinHeight;if(isPc()){if((mapContainerWidth/mapContainerHeight)<=bgWidth/bgHeight){bgVW=mapContainerWidth*bgZoom;bgVH=parseInt(bgVW*bgHeight/bgWidth)}else{bgVH=mapContainerHeight*bgZoom;bgVW=parseInt((bgVH*bgWidth)/bgHeight)}}else{if((mapContainerWidth/mapContainerHeight)<=bgWidth/bgHeight){bgVH=mapContainerHeight*bgZoom;bgVW=parseInt((bgVH*bgWidth)/bgHeight)}else{bgVW=mapContainerWidth*bgZoom;bgVH=parseInt(bgVW*bgHeight/bgWidth)}}bgVTop=parseInt((innerHeight+headerHeight-bgVH)/2);if(bgVTop=boxWidth/boxHeight){vBoxWidth=boxWidth;vBoxHeight=parseInt(vBoxWidth*videoHeight/videoWidth)}else{vBoxHeight=boxHeight;vBoxWidth=parseInt(vBoxHeight*videoWidth/videoHeight)}let vtop=($(window).height()-(vBoxHeight+12))/2;$(".player-inner").css({width:vBoxWidth,height:vBoxHeight});$(".player-outter").css({top:vtop})};document.getElementById("map").addEventListener("touchmove",function(a){if(a.target&&($(a.target).hasClass("content-box")||$(a.target).parents().hasClass("content-box"))){}else{a.preventDefault()}},false);let isResizing=false;window.onresize=function(){if(isResizing){return}isResizing=true;setTimeout(function(){fitScreen();isResizing=false},100)};let dragOffset={x:0,y:0};let dragStartPos={x:0,y:0};let offSetX=20;let dragHandler=$(".map-box");dragHandler.drag({onstart:function(c,a,d,b){dragOffset.x=dragHandler.offset().left;dragOffset.y=dragHandler.offset().top-headerHeight;dragStartPos.x=a;dragStartPos.y=d},onmove:function(c,a,d,b){let tx=a-dragStartPos.x+dragOffset.x;let ty=d-dragStartPos.y+dragOffset.y;console.log("tx",tx,"ty",ty);if(Math.sqrt(Math.pow(a-dragStartPos.x,2)+Math.pow(d-dragStartPos.y,2))>5){$(".area-board").css("pointer-events","none")}if(tx>0+offSetX||tx0||ty+headerHeight');$(".buoy-board").append(buoyDomItem)}if(spotData.area.shape){let coordsStr="";let spliter="";let coordsArr=spotData.area.coords.split(",");for(let k in coordsArr){let p=parseInt(coordsArr[k]*mapScale);coordsStr+=spliter+p;spliter=","}let areaDomItem=$('');$("#towntmap").append(areaDomItem)}}$(".area-item").mouseenter(function(){let areaIdx=$(this).attr("idx");areaIdx=areaIdxMap[areaIdx];let areaDom=".area-item-"+areaIdx;if(typeof($(areaDom).attr("isopen"))=="undefined"||$(areaDom).attr("isopen")=="0"){TweenMax.fromTo("#buoy-item-"+areaIdx,0.3,{y:-15},{y:-30,repeat:-1,yoyo:true})}});$(".area-item").mouseleave(function(){let areaIdx=$(this).attr("idx");areaIdx=areaIdxMap[areaIdx];let areaDom=".area-item-"+areaIdx;if(typeof($(areaDom).attr("isopen"))=="undefined"||$(areaDom).attr("isopen")=="0"){TweenMax.to("#buoy-item-"+areaIdx,0.3,{y:-15})}});$(".area-item").click(function(){let areaIdx=$(this).attr("idx");let spotDataOriginal=_hotspots[areaIdx];areaIdx=areaIdxMap[areaIdx];popupCloseDo(areaIdx);$(".area-item").attr("isOpen","0");let spotData=_hotspots[areaIdx];let type=spotData.type;if(type=="video"){let vid=spotData.vid;playVideo(vid)}else{if(type=="box"){$(".area-item-"+areaIdx).attr("isOpen","1");let fclass=(spotData.areaKbn==0)?"popup-box-f-left":"popup-box-f-right";let popupBox=$(spotData.handleName);$(".popup-box").addClass("hide");$(".popup-box").removeClass("popup-box-f-left");$(".popup-box").removeClass("popup-box-f-right");if(spotDataOriginal.type=="img"){popupBoxImgViewSet(popupBox,spotData,spotDataOriginal.imgTargetIdx)}else{popupBoxImgViewSet(popupBox,spotData)}popupBox.removeClass("hide");setTimeout(function(){$(".content-box").scrollTop(0)},0);popupBox.addClass(fclass);popupBox.find(".popup-container-grid").removeClass("hide");popupBox.removeClass("popup-box-detail");popupBox.removeClass("popup-box-detail-v");popupBox.removeClass("popup-box-detail-nolink");TweenMax.fromTo(popupBox,0.25,{opacity:0,scale:0.7},{opacity:1,scale:1,onComplete:function(){popupBox.css("transform","translate(0, -50%)")}});TweenMax.to("#buoy-item-"+areaIdx,0.3,{scale:1.4})}}})};let popupBoxImgViewSet=function(b,c,a){let imgSrc=JSON.parse(JSON.stringify(c.imgSrc));if(typeof(a)!="undefined"&&a>=0){let popOne=imgSrc.splice(a,1);imgSrc.splice(0,0,popOne[0]);console.log(imgSrc)}c.imgs=imgSrc;let imgArr=c.imgs;b.find(".image-outter").empty();for(let i in imgArr){let imgItem=imgArr[i];let dom="";if(i==0){dom=$('
')}else{dom=$('
')}b.find(".image-outter").append(dom);dom.on("click",contentItemImgHandle)}b.find(".show-more-btn").removeClass("hide")};$(".btn-close").click(function(){let popupBoxHandle=$(this).parents(".popup-box");TweenMax.fromTo(popupBoxHandle,0.25,{opacity:1,scale:1},{opacity:0,scale:0.4,onComplete:function(){popupBoxHandle.css("transform","translate(0, -50%)");popupBoxHandle.addClass("hide")}});popupCloseDo()});let popupCloseDo=function(a){let clickedIdx=areaIdxMap[a];$(".area-item").each(function(){if($(this).attr("isopen")=="1"){let areaIdx=$(this).attr("idx");if(typeof(clickedIdx)!=undefined&&clickedIdx==areaIdx){}else{TweenMax.to("#buoy-item-"+areaIdx,0.3,{y:-15,scale:1})}$(".area-item").eq(areaIdx).attr("isopen","0")}})};$(".menu-btn").click(function(){openMenu()});$(".menu-board").click(function(a){a.stopPropagation()});$(".menu-btn-close").click(function(){closeMenu()});function openMenu(){$(".menu-board").removeClass("hide");TweenMax.fromTo(".menu-board",0.2,{x:200},{x:0});$(".map-container").bind("click",closeMenu)}function closeMenu(){$(".menu-board").addClass("hide");$(".map-container").unbind("click",closeMenu)}$("body").mousewheel(function(b,c){var a=c>0?"Up":"Down";console.log("dir",a);let mapHeight=parseInt($(".map-box").css("height"));if(a=="Up"){if(innerHeight-headerHeight<=mapHeight){let top=parseInt($(".map-box").css("top"));let toTop=top+parseInt(mapHeight/50);toTop=toTop>0+headerHeight?0+headerHeight:toTop;$(".map-box").css("top",toTop)}}else{if(innerHeight-headerHeight<=mapHeight){let top=parseInt($(".map-box").css("top"));let toTop=top-parseInt(mapHeight/50);toTop=(toTop0){b=false;break}}return b};let contentItemImgHandle=function(){let clickIdx=$(this).index();let hotspotId=$(this).parents(".popup-box").attr("hotspotId");let imgArr=_hotspots[hotspotId].imgs;$(".image-pupop-viewer .image-viewer-outter").empty();let html='
';for(let i in imgArr){let imgSrc=imgArr[i];html+='
'}html+='
';$(".image-pupop-viewer .image-viewer-outter").append(html);$(".image-pupop-viewer").removeClass("hide");var a=new Swiper(".image-swiper-container",{loop:true,autoplay:false,initialSlide:clickIdx,navigation:{prevEl:".btn-swiper-prev",nextEl:".btn-swiper-next"},pagination:{el:".swiper-pagination",type:"fraction"}});$(".btn-swiper-close").click(function(){$(".image-pupop-viewer").addClass("hide");$(".image-pupop-viewer .image-viewer-outter").empty()})};let player=null;$(".content-item-v").click(function(){let hotspotId=$(this).parents(".popup-box").attr("hotspotId");let vid=_hotspots[hotspotId].vid;playVideo(vid)});let playVideo=function(a){$(".player-board").removeClass("hide");let playerDom=$('
');$(".player-inner").append(playerDom);player=new YKU.Player("youkuplayer",{styleid:"0",client_id:"add33ebd50a54298",vid:a,newPlayer:true,autoplay:true,events:{onPlayEnd:function(){},onPlayStart:function(){},onPlayerReady:function(){isPlayerReady=true}}})};$(".btn-video-close").click(function(){$(".player-inner").empty();player=null;$(".player-board").addClass("hide")});$(".show-more-btn").click(function(){$(this).addClass("hide");$(this).parent().find(".image-show-more-board").removeClass("hide")});