!function(t){"use strict";window.wvt=window.wvt||{},wvt.helper={},wvt.helper.pin={},wvt.helper.panoramaMap=function(o,e,i){var a=e.option.map,n=new Image,r=o.find(".wvt-panorama-map-image");"object"==typeof a&&null!==a&&(a=a.src),t(n).load(function(){o.removeClass("empty-map"),r.append(n),this.resizeImageWrapper(o,n),t(window).on("resize",this.resizeImageWrapper.bind(this,o,n)),_.each(e.pin,function(t,e){this.pin.createPin(wvt.helper.segmentName("pin",e),t,o)}.bind(this)),this.draggableMap(o,n,e.pin,i),this.singlePanoramaZoom(o)}.bind(this)).error(function(){o.attr("style","").addClass("empty-map"),r.append(n),t(window).unbind("resize",this.resizeImageWrapper)}).attr("src",a)},wvt.helper.resizeImageWrapper=function(o,e){var i=this.getImageSize(e,o.parent(),!0);void 0!==window.wvtp&&(i[3]=0),t(o).css("height",i[0]).css("width",i[1]).css("left",i[2]).css("top",i[3])},wvt.helper.getImageSize=function(o,e,i){var a,n,r=t(o).height(),p=t(o).width();0===r&&(r=o.height,p=o.width);var l=(r/p).toFixed(2),s=t(e).height(),c=t(e).width(),d=s/c.toFixed(2),v=function(){return[a=c*l,n=c,(c-n)/2,(s-a)/2]},h=function(){return[a=s,n=s/l,(c-n)/2,(s-a)/2]};return i?d>l?v():h():d>l?h():v()},wvt.helper.pin.createPin=function(o,e,i){var a=2*e.size,n=void 0!==wvt_global.lang.clicktocollapse?'title="'+wvt_global.lang.clicktocollapse+'"':"",r='<div class="wvt-panorama-map-pin-item '+e.key+'" '+n+'><div class="wvt-panorama-map-pin-circle pulse" data-id="'+o+'"></div></div>';(r=t(r).css({top:e.top+"%",left:e.left+"%"})).find("> div").css({width:a+"px",height:a+"px","margin-top":"-"+e.size+"px","margin-left":"-"+e.size+"px","background-color":e.color}),i.find(".wvt-panorama-map-pin").append(r),wvt.admin&&wvt.admin.pin?(r.mouseenter(wvt.admin.pin.pinMouseEnter.bind(this)).mouseleave(wvt.admin.pin.pinMouseLeave.bind(this)),r.on("click",wvt.admin.pin.pinClick.bind(this)),r.tooltipster({theme:"tooltipster-borderless"})):window.wvtp&&e.panorama?r.on("click",function(){var t=(i=i.parents(".wvt-panorama")).attr("id"),o=i.data("sequence"),a=["wvt",e.panorama,o].join("_"),n=wvtp.instance[t];(wvt.helper.showLoader(t),void 0===wvtp.scene[a])?wvt.helper.getPanorama(e.panorama).done(function(t){wvtp.scene[a]=wvt.helper.panoramaOption(t.option),n.addScene(a,wvtp.scene[a]),n.loadScene(a)}):n.loadScene(a)}):r.tooltipster({theme:"tooltipster-borderless"})},wvt.helper.singlePanoramaMap=function(o,e,i){(o=t("#"+o)).find(".wvt-single-map-container").remove(),o.append('<div class="wvt-single-map-container">'+this.createLoader()+'<div class="wvt-zoom-control"><div class="wvt-zoom-in"></div><div class="wvt-zoom-out"></div></div></div>'),this.singlePanoramaContainer(o,e.mapDimension),t(window).resize(function(){wvt.helper.singlePanoramaContainer(o,e.mapDimension)}),e.mapShow&&o.find(".wvt-single-map-container").css({visibility:"visible"}),void 0!==e.mapID&&e.mapID&&this.callAjaxMap(o.find(".wvt-single-map-container"),e.mapID,i)},wvt.helper.singlePanoramaContainer=function(t,o){var e=t.find(".pnlm-render-container").height()*o,i=t.find(".pnlm-render-container").width()*o;t.find(".wvt-single-map-container").css({height:e+"px",width:i+"px"})},wvt.helper.singlePanoramaZoom=function(t){var o=t.parents(".wvt-single-map-container"),e=o.find(".map-drag").height(),i=o.find(".map-drag").width(),a=.2*i,n=.2*e,r=1,p=function(t,e){o.find(".map-drag").css({width:t+"px",height:e+"px"}),o.find(".wvt-panorama-map-wrapper").css({width:t+"px",height:e+"px"})},l=function(t,e){o.find(".map-drag").css({top:t+"px",left:e+"px"})};o.find(".wvt-zoom-in").on("click",function(){if(r<4){p(i+=a,e+=n);var t=o.find(".map-drag").position().top,s=o.find(".map-drag").position().left;l(t-=.5*n,s-=.5*a),r++}}),o.find(".wvt-zoom-out").on("click",function(){if(o.width()<i-a&&o.height()<e-n&&r>-4){p(i-=a,e-=n);var t=o.find(".map-drag").position().top,s=o.find(".map-drag").position().left;t<-.5*n&&(t+=.5*n),e-(o.height()+Math.abs(t))<=0&&(t=-(e-o.height())),s<-.5*a&&(s+=.5*a),i-(o.width()+Math.abs(s))<=0&&(s=-(i-o.width())),l(t,s),r--}})},wvt.helper.callAjaxMap=function(t,o,e){wp.ajax.send("wvt_get_map",{data:{map_id:o}}).done(function(o){t.find(".map-drag").length?t.find(".map-drag").replaceWith('<div class="map-drag"><div class="wvt-panorama-map-wrapper"><div class="wvt-panorama-map-image"></div><div class="wvt-panorama-map-pin"></div></div></div>'):t.append('<div class="map-drag"><div class="wvt-panorama-map-wrapper"><div class="wvt-panorama-map-image"></div><div class="wvt-panorama-map-pin"></div></div></div>'),t.find(".wvt-tour-loader").fadeOut("slow"),wvt.helper.panoramaMap(t.find(".wvt-panorama-map-wrapper"),o.option,e)})},wvt.helper.draggableMap=function(o,e,i,a){var n=this.getImageSize(e,o.parent(),!0),r=o.parents(".wvt-single-map-container"),p=parseInt(r.width()/2),l=parseInt(r.height()/2),s=-(parseInt(n[0]/2)-l),c=-(parseInt(n[1]/2)-p);_.each(i,function(t,o){if(void 0!==t.panorama&&a===t.panorama){var e=n[1]-r.width(),i=n[0]-r.height();s=(s=parseFloat(t.top)*n[0]/100-l)<0?0:s>i?-i:-s,c=(c=parseFloat(t.left)*n[1]/100-p)<0?0:c>e?-e:-c}}),r.find(".map-drag").draggable({create:function(o){t(this).css({top:s+"px",left:c+"px"})},drag:function(t,o){var e=o.helper[0].parentNode,i=o.helper[0].clientWidth-e.clientWidth,a=o.helper[0].clientHeight-e.clientHeight;o.position.left>0?o.position.left=0:o.position.left<-i&&(o.position.left=-i),o.position.top>0?o.position.top=0:o.position.top<-a&&(o.position.top=-a)}})},wvt.helper.loader=function(o){t("#"+o).append(this.createLoader())},wvt.helper.hideLoader=function(o){t("#"+o).find("> .wvt-tour-loader").fadeOut("slow")},wvt.helper.showLoader=function(o){t("#"+o).find("> .wvt-tour-loader").fadeIn("fast")},wvt.helper.createLoader=function(){var t=window.wvt_global.global?window.wvt_global.global.load_scene:window.wvt_global.load_scene;return'<div class="wvt-tour-loader"><div class="'+t+'">'+this.createLoaderItem(t)+"</div></div>"},wvt.helper.createLoaderItem=function(t){var o="",e=3;"ball-grid-pulse"===t||"ball-grid-beat"===t?e=9:"ball-clip-rotate"===t||"ball-rotate"===t||"ball-scale"===t||"ball-scale-ripple"===t||"square-spin"===t||"triangle-skew-spin"===t||"semi-circle-spin"===t?e=1:"ball-clip-rotate-pulse"===t||"ball-clip-rotate-multiple"===t||"ball-zig-zag"===t||"ball-zig-zag-deflect"===t||"cube-transition"===t?e=2:"ball-pulse-rise"===t||"line-scale"===t||"line-scale-pulse-out"===t||"line-scale-pulse-out-rapid"===t||"pacman"===t?e=5:"ball-spin-fade-loader"===t||"line-spin-fade-loader"===t?e=8:"line-scale-party"===t&&(e=4);for(var i=1;i<=e;i++)o+="<div></div>";return o},wvt.helper.createToolbar=function(o,e,i){var a=(o=t("#"+o)).find(".wvt-toolbar-wrapper");a.length&&a.remove();var n=this.createToolbarWrapper(o),r=t(n).find(".wvt-zoom-control-wrapper");this.toolbarFullscreen(r,e,i),this.toolbarOrientation(r,e,i),this.toolbarZoomControl(r,e,i),this.toolbarAutorotateControl(r,e,i),this.toolbarTitle(n,e),this.toolbarScheme(o,e.toolbarScheme)},wvt.helper.toolbarScheme=function(o,e){t(o).attr("data-scheme",e)},wvt.helper.toolbarTitle=function(o,e){var i=""===e.name?'style="display: none"':"",a=""===e.name?'style="display: none"':"",n=t('<div class="wvt-panorama-title" '+i+"><h2 "+a+">"+e.name+"</h2></div>");o.append(n)},wvt.helper.createToolbarWrapper=function(o){var e=t('<div class="wvt-toolbar-wrapper"><div class="wvt-zoom-control-wrapper"></div></div>');return o.append(e),e},wvt.helper.toolbarZoomControl=function(o,e,i){var a=e.showZoomCtrl?"":'style="display: none"',n=t('<div class="wvt-zoom-control" '+a+'><div class="wvt-zoom-in"></div><div class="wvt-zoom-out"></div></div>');o.append(n),n.find(".wvt-zoom-in").on("click",function(){i.setHfov(i.getHfov()-10,200)}),n.find(".wvt-zoom-out").on("click",function(){i.setHfov(i.getHfov()+10,200)})},wvt.helper.toolbarAutorotateControl=function(o,e,i){var a=e.showRotateCtrl?"":'style="display: none"',n=t('<div class="wvt-autorotate-control" '+a+"></div>");o.append(n),e.autoRotate&&n.addClass("rotating"),n.on("click",function(){var t=e.autoRotateDirection,o=e.autoRotateSpeed;void 0!==window.wvt.admin&&(o=wvt.admin.option.getValue("autorotate_speed"),t=wvt.admin.option.getValue("autorotate")),n.hasClass("rotating")?(i.stopAutoRotate(o*t),n.removeClass("rotating")):(i.startAutoRotate(o*t),n.addClass("rotating"))})},wvt.helper.toolbarFullscreen=function(o,e,i){var a=e.showFullscreenCtrl?"":'style="display: none"',n=t('<div class="wvt-fullscreen-control" '+a+"></div>");o.append(n),n.on("click",function(){i.toggleFullscreen()})},wvt.helper.toolbarOrientation=function(o,e,i){var a=e.showOrientationCtrl?"":'style="display: none"',n=t('<div class="wvt-orientation-control" '+a+"></div>");o.append(n),n.on("click",function(){var o=t(this);o.hasClass("active")?i.stopOrientation():(i.startOrientation(),i.stopAutoRotate(),o.parent().find(".wvt-autorotate-control").removeClass("rotating")),o.toggleClass("active")})},wvt.helper.spotList=function(o,e,i){(o=t("#"+o)).find(".wvt-spotlist-container").remove(),this.prepareSpotList(o,e);var a=this.createSpotItem(e),n=o.find(".wvt-spotlist-container");n.find("ul").append(a),e.showSpotlist&&n.css({display:"block"}),this.scrollSpotList(o),this.toggleSpotList(o),this.clickSpotItem(o,i),t(window).resize(function(){wvt.helper.scrollSpotList(o)})},wvt.helper.prepareSpotList=function(t,o){var e='<div class="wvt-spotlist-container"><div class="btn-toggle"><i class="fa fa-list-ul"></i></div><div class="list-content"><span>'+window.wvt_global.lang.spotlist+"</span><ul></ul></div></div>";t.find(".wvt-toolbar-wrapper").append(e)},wvt.helper.clickSpotItem=function(o,e){o.find(".wvt-spotlist-container ul li").on("click",function(o){o.preventDefault();var i=t(this),a=JSON.parse(i.attr("data-coordinate"));e.lookAt(parseInt(a.pitch),parseInt(a.yaw),parseInt(a.hfov),1e3)})},wvt.helper.createSpotItem=function(t){var o="";return _.each(t.hotSpots,function(t,e){o+=wvt.helper.addSpotItem(t)}),o},wvt.helper.addSpotItem=function(t){var o="";if("badge"===t.shape)o='<img class="badge" src="'+(window.wvt_global.wvt_url+"/assets/img/badge/wvt-badge-"+t.badge+".png")+'">';else o="icon"===t.icontype?'<i class="fa '+t.icon+'"></i>':'<img src="'+t.iconimage.src+'">';return"<li data-id="+t.id+" data-coordinate="+JSON.stringify(t.coordinate)+">"+o+" "+t.title+"</li>"},wvt.helper.removeSpotItem=function(o){t(".wvt-spotlist-container").find(".list-content li[data-id="+o+"]").remove(),this.scrollSpotList(t(".panorama"))},wvt.helper.scrollSpotList=function(t){var o=t.find(".pnlm-render-container").height()-10,e=t.find(".wvt-spotlist-container .btn-toggle").height(),i=t.find(".wvt-spotlist-container ul").height(),a=document.querySelector(".wvt-spotlist-container ul");i>o-e&&(t.find(".wvt-spotlist-container").css({"max-height":o+"px"}),t.find(".wvt-spotlist-container ul").css({height:o-e+"px"}),a.scrollTop=0,new PerfectScrollbar(a))},wvt.helper.toggleSpotList=function(o){o.find(".wvt-spotlist-container .btn-toggle").on("click",function(e){e.stopPropagation();var i=t(this);"default"===o.attr("data-scheme")?i.parent().hasClass("expand")?(i.parent().find(".list-content ul").slideUp(),setTimeout(function(){i.parent().removeClass("expand")},300)):(i.parent().addClass("expand"),setTimeout(function(){i.parent().find(".list-content ul").slideDown()},300)):i.parent().hasClass("expand")?i.parent().removeClass("expand"):i.parent().addClass("expand")})},wvt.helper.prioritySort=function(t){var o=[],e=Object.keys(t).sort(function(o,e){return t[o].priority-t[e].priority});return _.each(e,function(e){o.push(t[e])}),o},wvt.helper.format=function(t){var o=Array.prototype.slice.call(arguments,1);return t.replace(/{(\d+)}/g,function(t,e){return void 0!==o[e]?o[e]:t})},wvt.helper.normalizeHotspotOption=function(t,o){return o.id=t,o.pitch=o.coordinate.pitch,o.yaw=o.coordinate.yaw,o.hfov=o.coordinate.hfov,o.type="info",o.cssClass="wvt-custom-hotspot wvt-"+t+" wvt-"+t.split("_")[0]+" "+o.key,o.createTooltipFunc=wvt.helper.hotspotTooltips.bind(this),o.createTooltipArgs=o,o},wvt.helper.hotspotTooltips=function(t,o){var e=this.hotspotTooltipIcons(t,o);e.attr("data-click",o.click).on("click",this.hotspotTooltipsClickBehavior.bind(this,e,o)),this.hotspotTooltipsItem(e,o)},wvt.helper.hotspotTooltipsItem=function(t,o){var e={};if(this.hotspotTooltipsDestroy(t),"none"!==o.hover){if("short"===o.hover)e.content=o.hovertext,"auto"!==o.hoverposition&&(e.side=o.hoverposition);else if("long"===o.hover)e.content='<div class="wvt-content-tooltips">'+o.hovercontent+"</div>",e.contentAsHTML=!0,"object"==typeof o.hoverlongposition?e.side=o.hoverlongposition:e.side=o.hoverlongposition.split(",");else if("post"===o.hover||"woo"===o.hover){var i={id:"post"===o.hover?o.post:o.woo,action:"post"===o.hover?"wvt_post_popup":"wvt_product_popup"};e.content='<i class="fa fa-circle-o-notch fa-spin">',e.contentAsHTML=!0,o.hovermaxwidth=o.hoverminwidth=0,wp.ajax.send(i.action,{data:{id:i.id,atc:o.wooatc}}).done(function(o){t.tooltipster("content",o)})}e.interactive=!0,e.minWidth=o.hoverminwidth,e.maxWidth=o.hovermaxwidth,e.theme="tooltipster-"+o.hovertheme,e.functionReady=function(t,o){var e=o.origin.getBoundingClientRect(),i=o.tooltip.getBoundingClientRect();o.tooltip.style.font=getComputedStyle(o.tooltip).font,o.origin.after(o.tooltip),o.tooltip.style.left=i.x-e.x+"px",o.tooltip.style.top=i.y-e.y+"px",o.origin.parentNode.style.zIndex="100"},e.functionAfter=function(t){t._$origin[0].parentElement.style.zIndex="1"},t.tooltipster(e)}},wvt.helper.hotspotTooltipsDestroy=function(t){t.hasClass("tooltipstered")&&t.tooltipster("destroy")},wvt.helper.hotspotTooltipsClickBehavior=function(o,e){if(void 0===e.spot)"none"===e.click||("url"===e.click?window.open(e.url):"video"===e.click?t.magnificPopup.open({items:{src:e.video,type:"iframe",prependTo:document.fullscreenElement}}):"gallery"===e.click&&t.magnificPopup.open({items:e.gallery,gallery:{enabled:!0},type:"image",prependTo:document.fullscreenElement}));else if(void 0!==window.wvtp&&e.spot){var i=t(e.div).parents(".wvt-panorama"),a=i.data("sequence"),n=t(i).attr("id"),r=wvtp.instance[n],p=["wvt",e.spot,a].join("_");if(this.showLoader(n),void 0===wvtp.scene[p])this.getPanorama(e.spot).done(function(t){wvtp.scene[p]=wvt.helper.panoramaOption(t.option),r.addScene(p,wvtp.scene[p]),r.loadScene(p)});else r.loadScene(p)}},wvt.helper.getPanorama=function(t){return wp.ajax.send("wvt_panorama",{data:{post_id:t}})},wvt.helper.hotspotTooltipIcons=function(o,e){var i=e.width,a=null;if("badge"===e.shape){t(o).css({height:i,width:i,"line-height":i+"px"}).addClass(e.shape);var n=window.wvt_global.wvt_url+"/assets/img/badge/wvt-badge-"+e.badge+".png";a=t('<img class="hotspot-element badge" src="'+n+'"/>'),t(o).append(a)}else t(o).css({"background-color":e.bgcolor,height:i,width:i,"line-height":i+"px"}).addClass(e.shape),"icon"===e.icontype&&(a=t('<i class="fa '+e.icon+' hotspot-element"></i>').css({color:e.iconcolor,"font-size":e.iconsize+"px","line-height":i+"px"}),t(o).append(a)),"image"===e.icontype&&(a=t('<img class="hotspot-element" src="'+e.iconimage.src+'"/>'),t(o).append(a));return a},wvt.helper.panoramaOption=function(t){var o={},e=[],i=document.createElement("canvas").getContext("experimental-webgl");return o.autoLoad=!0,o.name=t.option.title,o.type=t.option.type,o.mapID=t.option.mapid,o.mapShow="1"===t.option.enable_map,o.mapDimension=t.option.mapdimension/100,"equirectangular"===o.type?"1"===t.option.equirectangular_external?o.panorama=t.option.equirectangular_external_url:(i.getParameter(i.MAX_TEXTURE_SIZE)<=4096?o.panorama=t.option.equirectangular_fallback||wvt_global.placeholder:o.panorama=t.option.equirectangular||wvt_global.placeholder,"object"==typeof o.panorama&&null!==o.panorama&&(o.panorama=o.panorama.src)):"cubemap"===o.type&&(o.cubeMap=[],_.each(["front","back","left","right","top","bottom"],function(e){var i=t.option.cubemap[e]?t.option.cubemap[e]:wvt_global.placeholder;"object"==typeof i&&null!==i&&(i=i.src),o.cubeMap.push(i)})),o.toolbarScheme=t.option.toolbar_scheme,o.showZoomCtrl="1"===t.option.zoom,o.showFullscreenCtrl="1"===t.option.fullscreen,o.showOrientationCtrl="1"===t.option.orientation,o.compass="1"===t.option.compass,o.showSpotlist="1"===t.option.spotlist,o.pitch=parseInt(t.option.coordinate.pitch),o.yaw=parseInt(t.option.coordinate.yaw),o.hfov=parseInt(t.option.coordinate.hfov),o.northOffset=this.calculateNorth(parseInt(t.option.north)),o.height=t.option.height,o.showRotateCtrl="1"===t.option.autorotate_button,o.autoRotateSpeed=t.option.autorotate_speed,o.autoRotateDirection="clockwise"===t.option.autorotate_direction?-1:1,"1"===t.option.autorotate&&(o.autoRotate=o.autoRotateDirection*o.autoRotateSpeed,o.autoRotateInactivityDelay=3e3),o.strings={bylineLabel:"%s"},_.each(t.hotspot,function(t,o){e.push(this.normalizeHotspotOption(this.segmentName("hotspot",o),t))}.bind(this)),_.each(t.tour,function(t,o){e.push(this.normalizeHotspotOption(this.segmentName("tour",o),t))}.bind(this)),o.hotSpots=e,o},wvt.helper.calculateNorth=function(t){return t=(t=360-(t=parseInt(t)))>=360?t-360:t},wvt.helper.segmentName=function(t,o){return t+"_"+o},wvt.helper.scrollToTopScrollbar=function(t){document.querySelector(".wvt-option-body").scrollTop=void 0===t?0:t},wvt.helper.contextMenu=function(){var o="<a href='"+window.wvt_global.context_url+"' target='_blank'>"+window.wvt_global.context+"</a>";t(".pnlm-about-msg").html(o)}}(jQuery); |