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