TimberTrust/business_information/static/assets/js/vendor/venobox.min.js

1 line
15 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VenoBox=t()}(this,function(){"use strict";let e,t,o,n,s,i,a,r,l,d,c,v,u,b,p,g,f,m,y,x,L,h,w,k,S,C,E,q,M,A,P,T,j,H,O;const z='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor">',B=z+'<path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"/><path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3z"/></svg>',I=z+'<path fill-rule="evenodd" d="M3.5 6a.5.5 0 0 0-.5.5v8a.5.5 0 0 0 .5.5h9a.5.5 0 0 0 .5-.5v-8a.5.5 0 0 0-.5-.5h-2a.5.5 0 0 1 0-1h2A1.5 1.5 0 0 1 14 6.5v8a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 2 14.5v-8A1.5 1.5 0 0 1 3.5 5h2a.5.5 0 0 1 0 1h-2z"/><path fill-rule="evenodd" d="M7.646.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L8.5 1.707V10.5a.5.5 0 0 1-1 0V1.707L5.354 3.854a.5.5 0 1 1-.708-.708l3-3z"/></svg>',V=z+'<path fill-rule="evenodd" d="M10.854 7.146a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708 0l-1.5-1.5a.5.5 0 1 1 .708-.708L7.5 9.793l2.646-2.647a.5.5 0 0 1 .708 0z"/><path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"/><path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3z"/></svg>',R=document.createElement("div");let D=0,Q=0,N=0,Z=50,W=!1,X=new Image;const Y={bounce:["sk-bounce","sk-bounce-dot",2],chase:["sk-chase","sk-chase-dot",6],circle:["sk-circle","sk-circle-dot",12],"circle-fade":["sk-circle-fade","sk-circle-fade-dot",12],flow:["sk-flow","sk-flow-dot",3],fold:["sk-fold","sk-fold-cube",4],grid:["sk-grid","sk-grid-cube",9],plane:["sk-plane","",0],pulse:["sk-pulse","",5],swing:["sk-swing","sk-swing-dot",2],wander:["sk-wander","sk-wander-cube",3],wave:["sk-wave","sk-wave-rec",5]},$={selector:".venobox",autoplay:!1,bgcolor:"#fff",border:"0",infinigall:!1,maxWidth:"100%",navigation:!0,navKeyboard:!0,navTouch:!0,navSpeed:300,numeration:!1,overlayClose:!0,overlayColor:"rgba(23,23,23,0.95)",popup:!1,ratio:"16x9",share:!1,shareStyle:"pill",spinner:"bounce",spinColor:"#d2d2d2",titleattr:"title",titlePosition:"top",titleStyle:"bar",toolsBackground:"#1C1C1C",toolsColor:"#d2d2d2",onPreOpen:function(){return!0},onPostOpen:function(){},onPreClose:function(){return!0},onNavComplete:function(){},onContentLoaded:function(){},onInit:function(){},jQuerySelectors:!1};function F(e,t,o){if("[object Object]"===Object.prototype.toString.call(e)){let n;for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.call(o,e[n],n,e)}else{let n=0,s=e.length;for(n=0;n<s;n++)t.call(o,e[n],n,e)}}function K(e){return e}function U({timing:e,draw:t,duration:o}){let n=performance.now();requestAnimationFrame(function s(i){let a=(i-n)/o;a>1&&(a=1);let r=e(a);t(r),a<1&&requestAnimationFrame(s)})}function _(e){if(!e)return!1;y=!0,r=e,h=!1,w=!1,S=e.getAttribute("data-maxwidth")||e.settings.maxWidth,C=e.getAttribute("data-overlay")||e.settings.overlayColor,E=e.getAttribute("data-ratio")||e.settings.ratio,q=e.getAttribute("data-autoplay")||e.settings.autoplay,M=e.getAttribute("data-href")||e.getAttribute("href"),P=e.getAttribute(e.settings.titleattr)||""}function G(){return!(!r||!document.body.classList.contains("vbox-open"))&&((!r.settings.onPreClose||"function"!=typeof r.settings.onPreClose||(r.settings.onPreClose(r,p,j,H),!1!==r.settings.onPreClose))&&(document.body.removeEventListener("keydown",te),document.body.classList.remove("vbox-open"),r.focus(),void U({duration:200,timing:K,draw:function(e){k.style.opacity=1-e,1===e&&k.remove()}})))}function J(){ve(j)}function ee(){ve(H)}function te(e){27===e.keyCode&&G(),O||(37==e.keyCode&&!0===w&&ve(H),39==e.keyCode&&!0===h&&ve(j),O=setTimeout(()=>{O=null},100))}function oe(e){a.classList.contains("vbox-"+e)||function(){y=!1,a.style.opacity=0,a.innerHTML=x;let e=a.querySelector(":first-child");e.classList.add("vbox-child"),e.style.padding=r.settings.border,e.style.backgroundColor=r.settings.bgcolor,e.style.maxWidth=S,e.style.transform="scale(0.9)",e.style.transition="transform 200ms";let t=a.querySelector(".vbox-child img");t&&t.addEventListener("dragstart",function(e){e.preventDefault()}),i.scrollTo(0,0),e.style.transform="scale(1)",U({duration:200,timing:K,draw:function(e){a.style.opacity=e,1===e&&u.classList.add("vbox-hidden")}}),r.settings.onContentLoaded&&"function"==typeof r.settings.onContentLoaded&&r.settings.onContentLoaded(x)}()}function ne(e,t,o){let n;if(a.classList.add("vbox-loading"),-1!==e.search(/.+\.mp4|og[gv]|webm/))x='<div class="venoratio venoratio-'+t+'"><video src="'+e+'"'+(n=o?" autoplay":"")+" controls>Your browser does not support the video tag.</video></div>";else{let s,i=function(e){let t;return e.match(/(http:|https:|)\/\/(player.|www.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com))\/(video\/|embed\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/),RegExp.$3.indexOf("youtu")>-1?t="youtube":RegExp.$3.indexOf("vimeo")>-1&&(t="vimeo"),{type:t,id:RegExp.$6}}(e),a=(n=o?"?rel=0&autoplay=1":"?rel=0")+function(e){let t="",o=decodeURIComponent(e).split("?");if(void 0!==o[1]){let e,n,s=o[1].split("&");for(n=0;n<s.length;n++)t=t+"&"+(e=s[n].split("="))[0]+"="+e[1]}return encodeURI(t)}(e);"vimeo"==i.type?s="https://player.vimeo.com/video/":"youtube"==i.type&&(s="https://www.youtube.com/embed/"),x='<div class="venoratio venoratio-'+t+'"><iframe webkitallowfullscreen mozallowfullscreen allowfullscreen allow="autoplay" frameborder="0" src="'+s+i.id+a+'"></iframe></div>'}a.classList.remove("vbox-loading"),oe("animated")}function se(){var e;if(e=x,R.innerHTML=e,(g=R.querySelectorAll("img")).length){let e=0;F(g,function(t){let o=t.src;(X=new Image).onload=function(){++e==g.length&&(a.classList.remove("vbox-loading"),oe("animated"))},X.onerror=function(){++e==g.length&&(a.classList.remove("vbox-loading"),oe("animated"))},X.src=o})}else a.classList.remove("vbox-loading"),oe("animated")}function ie(e){if(!y){let t=.84*r.settings.navSpeed;a.style.transition="margin "+t+"ms ease-out, opacity "+t+"ms ease-out",A=v=e.pageY,D=Q=e.pageX,W=!0}}function ae(e){if(W){W=!1;let e=r,t=!1;(N=Q-D)<0&&h&&(e=j,t=!0),N>0&&w&&(e=H,t=!0),Math.abs(N)>=Z&&t?ve(e):(a.style.marginLeft=0,a.style.opacity=1)}}function re(e){if(W&&!y){Q=e.pageX,v=e.pageY,d=Q-D,c=v-A;let t=Math.abs(d);if(t>Math.abs(c)&&t<=180){let o=1.5*(1-t/180);e.preventDefault(),a.style.marginLeft=d+"px",a.style.opacity=o}}}function le(e){if(!e)return!1;T=e.dataset.gall,L=e.settings.numeration,f=e.settings.infinigall,o.innerHTML="";let s=e.dataset.vbtype;e.settings.share&&"iframe"!==s&&"inline"!==s&&"ajax"!==s&&function(e){if(navigator.canShare){const t={url:e};o.insertAdjacentHTML("beforeend",'<div class="vbox-link-btn vbox-share-mobile">'+I+"</div>"),o.querySelector(".vbox-share-mobile").addEventListener("click",function(e){e.preventDefault(),navigator.share(t)})}o.insertAdjacentHTML("beforeend",'<a target="_blank" href="'+e+'" download>'+B+"</a>"),o.insertAdjacentHTML("beforeend",'<div class="vbox-tooltip"><div class="vbox-link-btn vbox-share-copy"><span class="vbox-tooltip-text" id="myTooltip"></span>'+V+"</div ></div>"),o.querySelector(".vbox-share-copy").addEventListener("click",function(t){t.preventDefault();let o=document.getElementById("myTooltip");navigator.clipboard.writeText(e).then(function(){o.innerHTML='<div class="vbox-tooltip-inner">Copied</div>'},function(){console.log("copy failed")})})}(e.href),m=document.querySelectorAll('.vbox-item[data-gall="'+T+'"]'),l=Array.prototype.indexOf.call(m,e),m.length<2&&(f=!1,L=!1),j=m[l+1],H=m[l-1],!j&&f&&(j=m[0]),!H&&f&&(H=m[m.length-1]),m.length>=1?(p=l+1,t.innerHTML=p+" / "+m.length):p=1,L?t.classList.remove("vbox-hidden"):t.classList.add("vbox-hidden"),""!==P?n.classList.remove("vbox-hidden"):n.classList.add("vbox-hidden"),n.innerHTML=P,w=!1,h=!1,(j||f)&&(h=!0),(l>0||f)&&(w=!0),(w||h)&&e.settings.navTouch?(a.classList.add("vbox-grab"),a.addEventListener("touchstart",ie,!1),a.addEventListener("touchend",ae,!1),a.addEventListener("touchmove",re,!1),a.addEventListener("mousedown",ie,!1),a.addEventListener("mouseup",ae,!1),a.addEventListener("mouseout",ae,!1),a.addEventListener("mousemove",re,!1)):(a.classList.remove("vbox-grab"),a.removeEventListener("touchstart",ie,!1),a.removeEventListener("touchend",ae,!1),a.removeEventListener("touchmove",re,!1),a.removeEventListener("mousedown",ie,!1),a.removeEventListener("mouseup",ae,!1),a.removeEventListener("mouseout",ae,!1),a.removeEventListener("mousemove",re,!1));let i=k.querySelector(".vbox-next"),r=k.querySelector(".vbox-prev");w?r.classList.remove("vbox-hidden"):r.classList.add("vbox-hidden"),h?i.classList.remove("vbox-hidden"):i.classList.add("vbox-hidden"),e.settings.navigation||(i.classList.add("vbox-hidden"),r.classList.add("vbox-hidden"))}function de(t){e.style.backgroundColor=C,b.innerHTML=function(e){if(!e)return"Loading...";let t='<div class="sk-center '+e[0]+'">',o=0;for(o=0;o<e[2];o++)t+='<div class="'+e[1]+'"></div>';return t+="</div>"}(Y[t.settings.spinner]),k.style.setProperty("--sk-color",t.settings.spinColor),u.classList.remove("vbox-hidden"),o.classList.remove("vbox-top","vbox-bottom"),n.classList.remove("vbox-top","vbox-bottom"),"top"==t.settings.titlePosition?(n.classList.add("vbox-top"),o.classList.add("vbox-bottom")):(n.classList.add("vbox-bottom"),o.classList.add("vbox-top"));let s="bar"===t.settings.titleStyle?"100%":"auto",i="pill"===t.settings.titleStyle?"5em":"0",a="bar"===t.settings.shareStyle?"100%":"auto",r="pill"===t.settings.shareStyle?"5em":"0",l="transparent"===t.settings.titleStyle?"transparent":t.settings.toolsBackground,d="transparent"===t.settings.shareStyle?"transparent":t.settings.toolsBackground;k.style.setProperty("--vbox-title-width",s),k.style.setProperty("--vbox-title-radius",i),k.style.setProperty("--vbox-share-width",a),k.style.setProperty("--vbox-share-radius",r),k.style.setProperty("--vbox-tools-color",t.settings.toolsColor),k.style.setProperty("--vbox-title-background",l),k.style.setProperty("--vbox-share-background",d)}function ce(){if(!r)return!1;switch(r.dataset.vbtype){case"iframe":e=M,t=E,a.classList.add("vbox-loading"),x='<div class="venoratio venoratio-'+t+'"><iframe src="'+e+'"></iframe></div>',a.classList.remove("vbox-loading"),oe("animated");break;case"inline":!function(e){let t=document.querySelector(e);t&&(a.classList.add("vbox-loading"),x='<div class="vbox-inline">'+t.innerHTML+"</div>",a.classList.remove("vbox-loading"),oe("animated"))}(M);break;case"ajax":!function(e){a.classList.add("vbox-loading");let t=new XMLHttpRequest;t.open("GET",e,!0),t.onload=function(){x='<div class="vbox-inline">'+t.response+"</div>",se()},t.onerror=function(){x='<div class="vbox-inline"></div>',a.classList.remove("vbox-loading"),oe("animated")},t.send()}(M);break;case"video":ne(M,E,q);break;default:!function(e){X.onload=function(){x='<div class="vbox-child"><img src="'+e+'"></div>',a.classList.remove("vbox-loading"),oe("animated")},X.src=e}(M)}var e,t}function ve(e){if(!e||y||!document.body.classList.contains("vbox-open"))return!1;_(e),de(e);let t=.84*r.settings.navSpeed;a.style.transition="margin "+t+"ms ease-out, opacity "+t+"ms ease-out",e===H&&a.classList.add("swipe-right"),e===j&&a.classList.add("swipe-left"),u.classList.remove("vbox-hidden");let o=a.style.opacity;a.classList.add("vbox-animated","vbox-loading"),le(e),U({duration:r.settings.navSpeed,timing:K,draw:function(e){a.style.opacity=o-e/o,1===e&&(a.classList.remove("swipe-left","swipe-right","vbox-animated"),a.style.marginLeft=0,a.style.transition="",oe("loading"),y=!1,r.settings.onNavComplete&&"function"==typeof r.settings.onNavComplete&&r.settings.onNavComplete(r,p,j,H))}}),ce()}function ue(l){return!(document.body.classList.contains("vbox-open")||!l)&&(l.settings.onPreOpen&&"function"==typeof l.settings.onPreOpen&&l.settings.onPreOpen(l),!!l.settings.onPreOpen&&(_(l),document.body.insertAdjacentHTML("beforeend",s),document.body.classList.add("vbox-open"),k=document.querySelector(".vbox-overlay"),e=k.querySelector(".vbox-backdrop"),i=k.querySelector(".vbox-container"),a=i.querySelector(".vbox-content"),t=k.querySelector(".vbox-num"),o=k.querySelector(".vbox-share"),n=k.querySelector(".vbox-title"),u=k.querySelector(".vbox-preloader"),b=u.querySelector(".vbox-preloader-inner"),k.style.opacity=0,de(l),le(l),a.classList.add("vbox-animated","vbox-loading"),U({duration:200,timing:K,draw:function(e){k.style.opacity=e,1===e&&(a.classList.remove("vbox-animated"),y=!1,oe("loading"),r.settings.onPostOpen&&"function"==typeof r.settings.onPostOpen&&r.settings.onPostOpen(r,p,j,H))}}),ce(),l.settings.navKeyboard&&(document.body.addEventListener("keydown",te),document.body.addEventListener("keyup",()=>{O&&(clearTimeout(O),O=null)})),document.querySelector(".vbox-prev").addEventListener("click",function(){ve(H)}),document.querySelector(".vbox-next").addEventListener("click",function(){ve(j)}),void k.addEventListener("click",function(e){let t=document.querySelector(".vbox-close");t&&(t.contains(e.target)||t===e.target||r.settings.overlayClose&&e.target.classList.contains("vbox-overlay")||e.target.classList.contains("vbox-content")||e.target.classList.contains("vbox-backdrop")||e.target.classList.contains("vbox-close")||e.target.classList.contains("vbox-preloader")||e.target.classList.contains("vbox-container"))&&G()})))}const be=function(e){const t={};let o=function(e,t){let o={};return F(e,function(t,n){o[n]=e[n]}),F(t,function(e,n){o[n]=t[n]}),o}($,e||{});return t.close=G,t.next=J,t.prev=ee,t.open=ue,t.settings=o,function(e,t){t.onInit&&"function"==typeof t.onInit&&t.onInit(e);let o=t.jQuerySelectors||document.querySelectorAll(t.selector);if(s='<div class="vbox-overlay"><div class="vbox-backdrop"></div><div class="vbox-preloader"><div class="vbox-preloader-inner"></div></div><div class="vbox-container"><div class="vbox-content"></div></div><div class="vbox-title"></div><div class="vbox-left-corner"><div class="vbox-num">0/0</div></div><div class="vbox-close"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" class="vbox-close-icon" viewBox="0 0 32 32"><path d="M 7.21875 5.78125 L 5.78125 7.21875 L 14.5625 16 L 5.78125 24.78125 L 7.21875 26.21875 L 16 17.4375 L 24.78125 26.21875 L 26.21875 24.78125 L 17.4375 16 L 26.21875 7.21875 L 24.78125 5.78125 L 16 14.5625 Z"/></svg></div><a class="vbox-next"><svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 32 32"><path d="M 21.1875 9.28125 L 19.78125 10.71875 L 24.0625 15 L 4 15 L 4 17 L 24.0625 17 L 19.78125 21.28125 L 21.1875 22.71875 L 27.90625 16 Z"/></svg></a><a class="vbox-prev"><svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 32 32"><path d="M 10.8125 9.28125 L 4.09375 16 L 10.8125 22.71875 L 12.21875 21.28125 L 7.9375 17 L 28 17 L 28 15 L 7.9375 15 L 12.21875 10.71875 Z"/></svg></a><div class="vbox-share"></div></div>',F(o,function(e){if(e.classList.contains("vbox-item"))return!0;e.settings=t,e.classList.add("vbox-item"),e.addEventListener("click",function(t){return t.preventDefault(),e.blur(),ue(e),!1})}),t.popup){let e=document.querySelector(t.popup);e.settings=t,ue(e)}}(t,o),t};return"function"==typeof jQuery&&jQuery.fn.extend({venobox:function(e){const t=e||{};t.jQuerySelectors=this,new be({pluginoptions:t})}}),be});