Comparing version 2.0.1 to 2.0.2
@@ -1,1 +0,1 @@ | ||
!function(e,t){if("function"==typeof define&&define.amd)define("GLightbox",["module"],t);else if("undefined"!=typeof exports)t(module);else{var i={exports:{}};t(i),e.GLightbox=i.exports}}(this,function(e){"use strict";var t=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i),s=null!==n||void 0!==document.createTouch||"ontouchstart"in window||"onmsgesturechange"in window||navigator.msMaxTouchPoints,o=document.getElementsByTagName("html")[0],l=function(){var e=void 0,t=document.createElement("fakeelement"),i={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in i)if(void 0!==t.style[e])return i[e]}(),r=function(){var e=void 0,t=document.createElement("fakeelement"),i={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(e in i)if(void 0!==t.style[e])return i[e]}(),a=Date.now(),d=[],c={},u={selector:"glightbox",skin:"clean",closeButton:!0,startAt:0,autoplayVideos:!0,descPosition:"bottom",width:900,height:506,videosWidth:960,videosHeight:540,beforeSlideChange:null,afterSlideChange:null,beforeSlideLoad:null,afterSlideLoad:null,onOpen:null,onClose:null,loopAtEnd:!1,touchNavigation:!0,keyboardNavigation:!0,closeOnOutsideClick:!0,jwplayer:{api:null,licenseKey:null,params:{width:"100%",aspectratio:"16:9",stretching:"uniform"}},vimeo:{api:"https://player.vimeo.com/api/player.js",params:{api:1,title:0,byline:0,portrait:0}},youtube:{api:"https://www.youtube.com/iframe_api",params:{enablejsapi:1,showinfo:0}},openEffect:"zoomIn",closeEffect:"zoomOut",slideEffect:"slide",moreText:"See more",moreLength:60,lightboxHtml:"",cssEfects:{fade:{in:"fadeIn",out:"fadeOut"},zoom:{in:"zoomIn",out:"zoomOut"},slide:{in:"slideInRight",out:"slideOutLeft"},slide_back:{in:"slideInLeft",out:"slideOutRight"}}};u.slideHtml='<div class="gslide"> <div class="gslide-inner-content"> <div class="ginner-container"> <div class="gslide-media"> </div> <div class="gslide-description"> <div class="gdesc-inner"> <h4 class="gslide-title"></h4> <div class="gslide-desc"></div> </div> </div> </div> </div> </div>';function h(){var e={},t=!1,i=0,n=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(t=arguments[0],i++);for(var s=function(i){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t&&"[object Object]"===Object.prototype.toString.call(i[n])?e[n]=h(!0,e[n],i[n]):e[n]=i[n])};i<n;i++){s(arguments[i])}return e}u.lightboxHtml='<div id="glightbox-body" class="glightbox-container"> <div class="gloader visible"></div> <div class="goverlay"></div> <div class="gcontainer"> <div id="glightbox-slider" class="gslider"></div> <a class="gnext"></a> <a class="gprev"></a> <a class="gclose"></a> </div> </div>';var v={isFunction:function(e){return"function"==typeof e},isString:function(e){return"string"==typeof e},isNode:function(e){return!(!e||!e.nodeType||1!=e.nodeType)},isArray:function(e){return Array.isArray(e)},isArrayLike:function(e){return e&&e.length&&isFinite(e.length)},isObject:function(e){return"object"===(void 0===e?"undefined":i(e))&&null!=e&&!v.isFunction(e)&&!v.isArray(e)},isNil:function(e){return null==e},has:function(e,t){return null!==e&&hasOwnProperty.call(e,t)},size:function(e){if(v.isObject(e)){if(e.keys)return e.keys().length;var t=0;for(var i in e)v.has(e,i)&&t++;return t}return e.length},isNumber:function(e){return!isNaN(parseFloat(e))&&isFinite(e)}};function f(e,t){if((v.isNode(e)||e===window||e===document)&&(e=[e]),v.isArrayLike(e)||v.isObject(e)||(e=[e]),0!=v.size(e))if(v.isArrayLike(e)&&!v.isObject(e))for(var i=e.length,n=0;n<i&&!1!==t.call(e[n],e[n],n,e);n++);else if(v.isObject(e))for(var s in e)if(v.has(e,s)&&!1===t.call(e[s],e[s],s,e))break}function g(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=e[a]=e[a]||[],s={all:n,evt:null,found:null};return t&&i&&v.size(n)>0&&f(n,function(e,n){if(e.eventName==t&&e.fn.toString()==i.toString())return s.found=!0,s.evt=n,!1}),s}function p(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.onElement,n=t.withCallback,s=t.avoidDuplicate,o=void 0===s||s,l=t.once,r=void 0!==l&&l,a=t.useCapture,d=void 0!==a&&a,c=arguments[2],u=i||[];function h(e){v.isFunction(n)&&n.call(c,e,this),r&&h.destroy()}return v.isString(u)&&(u=document.querySelectorAll(u)),h.destroy=function(){f(u,function(t){var i=g(t,e,h);i.found&&i.all.splice(i.evt,1),t.removeEventListener&&t.removeEventListener(e,h,d)})},f(u,function(t){var i=g(t,e,h);(t.addEventListener&&o&&!i.found||!o)&&(t.addEventListener(e,h,d),i.all.push({eventName:e,fn:h}))}),h}function m(e,t){b(e,t)||(e.classList?e.classList.add(t):e.className+=" "+t)}function y(e,t){var i=t.split(" ");i.length>1?f(i,function(t){y(e,t)}):e.classList?e.classList.remove(t):e.className=e.className.replace(t,"")}function b(e,t){return e.classList?e.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(e.className)}function w(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!e||""===t)return!1;if("none"==t)return v.isFunction(i)&&i(),!1;var n=t.split(" ");f(n,function(t){m(e,"g"+t)}),p(r,{onElement:e,avoidDuplicate:!1,once:!0,withCallback:function(e,t){f(n,function(e){y(t,"g"+e)}),v.isFunction(i)&&i()}})}function S(e){var t=document.createDocumentFragment(),i=document.createElement("div");for(i.innerHTML=e;i.firstChild;)t.appendChild(i.firstChild);return t}function x(e,t){for(;e!==document.body;){if("function"==typeof(e=e.parentElement).matches?e.matches(t):e.msMatchesSelector(t))return e}}function k(e){e.style.display="block"}function E(e){e.style.display="none"}var C=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments[1],i={href:"",title:"",type:"",description:"",descPosition:"bottom",effect:"",node:e};if(v.isObject(e)&&!v.isNode(e))return h(i,e);var n="",s=e.getAttribute("data-glightbox"),o=e.nodeName.toLowerCase();if("a"===o&&(n=e.href),"img"===o&&(n=e.src),i.href=n,f(i,function(n,s){v.has(t,s)&&(i[s]=t[s]);var o=e.dataset[s];v.isNil(o)||(i[s]=o)}),i.type||(i.type=j(n)),v.isNil(s)){if("a"==o){var l=e.title;v.isNil(l)||""===l||(i.title=l)}if("img"==o){var r=e.alt;v.isNil(r)||""===r||(i.title=r)}var a=e.getAttribute("data-description");v.isNil(a)||""===a||(i.description=a)}else{var d=[];f(i,function(e,t){d.push(";\\s?"+t)}),d=d.join("\\s?:|"),""!==s.trim()&&f(i,function(e,t){var n=s,o=new RegExp("s?"+t+"s?:s?(.*?)("+d+"s?:|$)"),l=n.match(o);if(l&&l.length&&l[1]){var r=l[1].trim().replace(/;\s*$/,"");i[t]=r}})}var c=e.querySelector(".glightbox-desc");c&&(i.description=c.innerHTML);var u="video"==i.type?t.videosWidth:t.width,g="video"==i.type?t.videosHeight:t.height;return i.width=v.has(i,"width")?i.width:u,i.height=v.has(i,"height")?i.height:g,i},A=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(b(e,"loaded"))return!1;v.isFunction(this.settings.beforeSlideLoad)&&this.settings.beforeSlideLoad(e,i);var o=i.type,l=i.descPosition,r=e.querySelector(".gslide-media"),a=e.querySelector(".gslide-title"),u=e.querySelector(".gslide-desc"),f=e.querySelector(".gdesc-inner"),g=s;if(v.isFunction(this.settings.afterSlideLoad)&&(g=function(){v.isFunction(s)&&s(),t.settings.afterSlideLoad(e,i)}),""==i.title&&""==i.description?f&&f.parentNode.removeChild(f):(a&&""!==i.title?a.innerHTML=i.title:a.parentNode.removeChild(a),u&&""!==i.description?n&&this.settings.moreLength>0?(i.smallDescription=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:50,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=i;if((e=e.trim()).length<=t)return e;var s=e.substr(0,t-1);if(!n)return s;return s+'... <a href="#" class="desc-more">'+i+"</a>"}(i.description,this.settings.moreLength,this.settings.moreText),u.innerHTML=i.smallDescription,function e(t,i){var n=t.querySelector(".desc-more");if(!n)return!1;p("click",{onElement:n,withCallback:function(t,n){t.preventDefault();var s=document.body,o=x(n,".gslide-desc");if(!o)return!1;o.innerHTML=i.description,m(s,"gdesc-open");var l=p("click",{onElement:[s,x(o,".gslide-description")],withCallback:function(t,n){"a"!==t.target.nodeName.toLowerCase()&&(y(s,"gdesc-open"),m(s,"gdesc-closed"),o.innerHTML=i.smallDescription,e(o,i),setTimeout(function(){y(s,"gdesc-closed")},400),l.destroy())}})}})}.apply(this,[u,i])):u.innerHTML=i.description:u.parentNode.removeChild(u),m(r.parentNode,"desc-"+l),m(f.parentNode,"description-"+l)),m(r,"gslide-"+o),m(e,"loaded"),"video"===o)return r.innerHTML='<div class="gvideo-wrapper"></div>',void function(e,t,i){var s=this,o="gvideo"+t.index,l=e.querySelector(".gvideo-wrapper"),r=t.href,a=location.protocol.replace(":","");"file"==a&&(a="http");if(r.match(/vimeo\.com\/([0-9]*)/)){var u=/vimeo.*\/(\d+)/i.exec(r),f=L(this.settings.vimeo.params),g=a+"://player.vimeo.com/video/"+u[1]+"?"+f;N(this.settings.vimeo.api);l.parentNode.style.maxWidth=t.width+"px",l.style.width=t.width+"px",l.style.maxHeight=t.height+"px";var p=T({url:g,callback:function(){q(function(){return"undefined"!=typeof Vimeo},function(){var e=new Vimeo.Player(p);c[o]=e,v.isFunction(i)&&i()})},allow:"autoplay; fullscreen",appendTo:l});p.id=o,p.className="vimeo-video gvideo",this.settings.autoplayVideos&&!n&&(p.className+=" wait-autoplay")}if(r.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||r.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)){var y=h(this.settings.youtube.params,{playerapiid:o}),b=L(y),w=function(e){var t="";t=void 0!==(e=e.replace(/(>|<)/gi,"").split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/))[2]?(t=e[2].split(/[^0-9a-z_\-]/i))[0]:e;return t}(r),x=a+"://www.youtube.com/embed/"+w+"?"+b;N(this.settings.youtube.api);l.parentNode.style.maxWidth=t.width+"px",l.style.width=t.width+"px",l.style.maxHeight=t.height+"px";var k=T({url:x,callback:function(){if(!v.isNil(YT)&&YT.loaded){var e=new YT.Player(k);c[o]=e}else d.push(k);v.isFunction(i)&&i()},allow:"autoplay; fullscreen",appendTo:l});k.id=o,k.className="youtube-video gvideo",this.settings.autoplayVideos&&!n&&(k.className+=" wait-autoplay")}if(null!==r.match(/\.(mp4|ogg|webm)$/)){var E='<video id="'+o+'" ';E+='style="background:#000; width: '+t.width+"px; height: "+t.height+'px;" ',E+='preload="metadata" ',E+='x-webkit-airplay="allow" ',E+='webkit-playsinline="" ',E+="controls ",E+='class="gvideo">';var C=r.toLowerCase().split(".").pop(),A={mp4:"",ogg:"",webm:""};for(var O in A[C]=r,A)if(A.hasOwnProperty(O)){var j=A[O];t.hasOwnProperty(O)&&(j=t[O]),""!==j&&(E+='<source src="'+j+'" type="video/'+O+'">')}var I=S(E+="</video>");l.appendChild(I);var B=document.getElementById(o);if(null!==this.settings.jwplayer&&null!==this.settings.jwplayer.api){this.settings.jwplayer;var F=this.settings.jwplayer.api;if(!F)return console.warn("Missing jwplayer api file"),v.isFunction(i)&&i(),!1;N(F,function(){var e=h(s.settings.jwplayer.params,{width:t.width+"px",height:t.height+"px",file:r});jwplayer.key=s.settings.jwplayer.licenseKey;var n=jwplayer(o);n.setup(e),c[o]=n,n.on("ready",function(){m(B=l.querySelector(".jw-video"),"gvideo"),B.id=o,v.isFunction(i)&&i()})})}else m(B,"html5-video"),c[o]=B,v.isFunction(i)&&i()}}.apply(this,[e,i,g]);if("external"===o){var w=T({url:i.href,width:i.width,height:i.height,callback:g});return r.parentNode.style.maxWidth=i.width+"px",void r.appendChild(w)}if("inline"!==o){if("image"===o){var k=new Image;return k.addEventListener("load",function(){v.isFunction(g)&&g()},!1),k.src=i.href,void r.appendChild(k)}v.isFunction(g)&&g()}else(function(e,t,i){var n=e.querySelector(".gslide-media"),s=t.href.split("#").pop().trim(),o=document.getElementById(s);if(!o)return!1;var l=o.cloneNode(!0);l.style.height=t.height+"px",l.style.maxWidth=t.width+"px",m(l,"ginlined-content"),n.appendChild(l),v.isFunction(i)&&i();return}).apply(this,[e,i,g])};function T(e){var t=e.url,i=e.width,s=e.height,o=e.allow,l=e.callback,r=e.appendTo,a=document.createElement("iframe"),d=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;return a.className="vimeo-video gvideo",a.src=t,s&&(a.style.height=n&&d<767?"":s+"px"),i&&(a.style.width=i+"px"),o&&a.setAttribute("allow",o),a.onload=function(){m(a,"iframe-ready"),v.isFunction(l)&&l()},r&&r.appendChild(a),a}function N(e,t){if(v.isNil(e))console.error("Inject videos api error");else{var i=document.querySelectorAll('script[src="'+e+'"]');if(v.isNil(i)||0==i.length){var n=document.createElement("script");return n.type="text/javascript",n.src=e,n.onload=function(){v.isFunction(t)&&t()},document.body.appendChild(n),!1}v.isFunction(t)&&t()}}function O(){for(var e=0;e<d.length;e++){var t=d[e],i=new YT.Player(t);c[t.id]=i}}function q(e,t,i,n){if(e())t();else{i||(i=100);var s=void 0,o=setInterval(function(){e()&&(clearInterval(o),s&&clearTimeout(s),t())},i);n&&(s=setTimeout(function(){clearInterval(o)},n))}}function L(e){var t="",i=0;return f(e,function(e,n){i>0&&(t+="&"),t+=n+"="+e,i+=1}),t}void 0!==window.onYouTubeIframeAPIReady?window.onYouTubeIframeAPIReady=function(){window.onYouTubeIframeAPIReady(),O()}:window.onYouTubeIframeAPIReady=O;var j=function(e){var t=e;if(null!==(e=e.toLowerCase()).match(/\.(jpeg|jpg|gif|png|apn|webp|svg)$/))return"image";if(e.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||e.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/))return"video";if(e.match(/vimeo\.com\/([0-9]*)/))return"video";if(null!==e.match(/\.(mp4|ogg|webm)$/))return"video";if(e.indexOf("#")>-1&&""!==t.split("#").pop().trim())return"inline";return e.includes("gajax=true")?"ajax":"external"};function I(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(""==t)return e.style.webkitTransform="",e.style.MozTransform="",e.style.msTransform="",e.style.OTransform="",e.style.transform="",!1;e.style.webkitTransform=t,e.style.MozTransform=t,e.style.msTransform=t,e.style.OTransform=t,e.style.transform=t}function B(e){var t=e.querySelector(".gslide-media"),i=e.querySelector(".gslide-description");m(t,"greset"),I(t,"translate3d(0, 0, 0)");p(l,{onElement:t,once:!0,withCallback:function(e,i){y(t,"greset")}});t.style.opacity="",i&&(i.style.opacity="")}var F=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.settings=h(u,t||{}),this.effectsClasses=this.getAnimationClasses()}return t(e,[{key:"init",value:function(){var e=this;this.baseEvents=p("click",{onElement:"."+this.settings.selector,withCallback:function(t,i){t.preventDefault(),e.open(i)}})}},{key:"open",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(this.elements=this.getElements(e),0==this.elements.length)return!1;this.activeSlide=null,this.prevActiveSlideIndex=null,this.prevActiveSlide=null;var t=this.settings.startAt;e&&(t=this.elements.indexOf(e))<0&&(t=0),this.build(),w(this.overlay,"none"==this.settings.openEffect?"none":this.settings.cssEfects.fade.in);var i=document.body;if(i.style.width=i.offsetWidth+"px",m(i,"glightbox-open"),m(o,"glightbox-open"),n&&(m(o,"glightbox-mobile"),this.settings.slideEffect="slide"),this.showSlide(t,!0),1==this.elements.length?(E(this.prevButton),E(this.nextButton)):(k(this.prevButton),k(this.nextButton)),this.lightboxOpen=!0,v.isFunction(this.settings.onOpen)&&this.settings.onOpen(),n&&s&&this.settings.touchNavigation)return function(){var e=this;if(this.events.hasOwnProperty("touchStart"))return!1;var t=void 0,i=void 0,n=void 0,s=!1,o=!1,l=!1,r=!1,a={},d={},c=(this.slidesContainer,null),u=0,h=0,v=null,f=null,g=null,w=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,S=(window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,document.body);this.events.doctouchmove=p("touchmove",{onElement:document,withCallback:function(e,t){if(b(S,"gdesc-open"))return e.preventDefault(),!1},useCapture:{passive:!1}}),this.events.touchStart=p("touchstart",{onElement:S,withCallback:function(t,i){b(S,"gdesc-open")||(m(S,"touching"),c=e.getActiveSlide(),v=c.querySelector(".gslide-image"),f=c.querySelector(".gslide-media"),g=c.querySelector(".gslide-description"),e.index,d=t.targetTouches[0],a.pageX=t.targetTouches[0].pageX,a.pageY=t.targetTouches[0].pageY,u=t.targetTouches[0].clientX,h=t.targetTouches[0].clientY)}}),this.events.gestureStart=p("gesturestart",{onElement:S,withCallback:function(e,t){v&&(e.preventDefault(),l=!0)}}),this.events.gestureChange=p("gesturechange",{onElement:S,withCallback:function(e,t){e.preventDefault(),I(v,"scale("+e.scale+")")}}),this.events.gesturEend=p("gestureend",{onElement:S,withCallback:function(e,t){l=!1,e.scale<1?(r=!1,I(v,"scale(1)")):r=!0}}),this.events.touchMove=p("touchmove",{onElement:S,withCallback:function(v,p){if(b(S,"touching")&&!(b(S,"gdesc-open")||l||r)){v.preventDefault(),d=v.targetTouches[0];var m=c.querySelector(".gslide-inner-content").offsetHeight,y=c.querySelector(".gslide-inner-content").offsetWidth,x=v.targetTouches[0].clientX,k=v.targetTouches[0].clientY,E=u-x,C=h-k;if(Math.abs(E)>Math.abs(C)?(s=!1,o=!0):(o=!1,s=!0),s){if(i=d.pageY-a.pageY,Math.abs(i)>=0||s){var A=.75-Math.abs(i)/m;f.style.opacity=A,g&&(g.style.opacity=A),I(f,"translate3d(0, "+i+"px, 0)")}}else if(t=d.pageX-a.pageX,n=100*t/w,o){if(e.index+1==e.elements.length&&t<-60)return B(c),!1;if(e.index-1<0&&t>60)return B(c),!1;var T=.75-Math.abs(t)/y;f.style.opacity=T,g&&(g.style.opacity=T),I(f,"translate3d("+n+"%, 0, 0)")}}},useCapture:{passive:!1}}),this.events.touchEnd=p("touchend",{onElement:S,withCallback:function(l,r){i=d.pageY-a.pageY,t=d.pageX-a.pageX,n=100*t/w,y(S,"touching");var u=c.querySelector(".gslide-inner-content").offsetHeight,h=c.querySelector(".gslide-inner-content").offsetWidth;if(s){var v=u/2;return s=!1,Math.abs(i)>=v?void e.close():void B(c)}if(o){o=!1;var f="prev",g=!0;if(t<0&&(f="next",t=Math.abs(t)),"prev"==f&&e.index-1<0&&(g=!1),"next"==f&&e.index+1>=e.elements.length&&(g=!1),g&&t>=h/2-90)return void("next"==f?e.nextSlide():e.prevSlide());B(c)}}})}.apply(this),!1;this.settings.keyboardNavigation&&function(){var e=this;if(this.events.hasOwnProperty("keyboard"))return!1;this.events.keyboard=p("keydown",{onElement:window,withCallback:function(t,i){var n=(t=t||window.event).keyCode;39==n&&e.nextSlide(),37==n&&e.prevSlide(),27==n&&e.close()}})}.apply(this)}},{key:"showSlide",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];k(this.loader),this.index=t;var n=this.slidesContainer.querySelector(".current");n&&y(n,"current"),this.slideAnimateOut();var s=this.slidesContainer.querySelectorAll(".gslide")[t];if(k(this.slidesContainer),b(s,"loaded"))this.slideAnimateIn(s,i),E(this.loader);else{k(this.loader);var o=C(this.elements[t],this.settings);o.index=t,A.apply(this,[s,o,function(){E(e.loader),e.slideAnimateIn(s,i)}])}this.preloadSlide(t+1),this.preloadSlide(t-1),y(this.nextButton,"disabled"),y(this.prevButton,"disabled"),0===t?m(this.prevButton,"disabled"):t===this.elements.length-1&&!0!==this.settings.loopAtEnd&&m(this.nextButton,"disabled"),this.activeSlide=s}},{key:"preloadSlide",value:function(e){var t=this;if(e<0||e>this.elements.length)return!1;if(v.isNil(this.elements[e]))return!1;var i=this.slidesContainer.querySelectorAll(".gslide")[e];if(b(i,"loaded"))return!1;var n=C(this.elements[e],this.settings);n.index=e;var s=n.sourcetype;"video"==s||"external"==s?setTimeout(function(){A.apply(t,[i,n])},200):A.apply(this,[i,n])}},{key:"prevSlide",value:function(){var e=this.index-1;if(e<0)return!1;this.goToSlide(e)}},{key:"nextSlide",value:function(){var e=this.index+1;if(e>this.elements.length)return!1;this.goToSlide(e)}},{key:"goToSlide",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e>-1&&(this.prevActiveSlide=this.activeSlide,this.prevActiveSlideIndex=this.index,e<this.elements.length?this.showSlide(e):!0===this.settings.loopAtEnd&&(e=0,this.showSlide(e)))}},{key:"slideAnimateIn",value:function(e,t){var i=this,s=e.querySelector(".gslide-media"),o=e.querySelector(".gslide-description"),l={index:this.prevActiveSlideIndex,slide:this.prevActiveSlide},r={index:this.index,slide:this.activeSlide};if(s.offsetWidth>0&&o&&(E(o),e.querySelector(".ginner-container").style.maxWidth=s.offsetWidth+"px",o.style.display=""),y(e,this.effectsClasses),t)w(e,this.settings.openEffect,function(){!n&&i.settings.autoplayVideos&&i.playSlideVideo(e),v.isFunction(i.settings.afterSlideChange)&&i.settings.afterSlideChange.apply(i,[l,r])});else{var a=this.settings.slideEffect,d="none"!==a?this.settings.cssEfects[a].in:a;this.prevActiveSlideIndex>this.index&&"slide"==this.settings.slideEffect&&(d=this.settings.cssEfects.slide_back.in),w(e,d,function(){!n&&i.settings.autoplayVideos&&i.playSlideVideo(e),v.isFunction(i.settings.afterSlideChange)&&i.settings.afterSlideChange.apply(i,[l,r])})}m(e,"current")}},{key:"slideAnimateOut",value:function(){if(!this.prevActiveSlide)return!1;var e=this.prevActiveSlide;y(e,this.effectsClasses),m(e,"prev");var t=this.settings.slideEffect,i="none"!==t?this.settings.cssEfects[t].out:t;this.stopSlideVideo(e),v.isFunction(this.settings.beforeSlideChange)&&this.settings.beforeSlideChange.apply(this,[{index:this.prevActiveSlideIndex,slide:this.prevActiveSlide},{index:this.index,slide:this.activeSlide}]),this.prevActiveSlideIndex>this.index&&"slide"==this.settings.slideEffect&&(i=this.settings.cssEfects.slide_back.out),w(e,i,function(){var t=e.querySelector(".gslide-media"),i=e.querySelector(".gslide-description");t.style.transform="",y(t,"greset"),t.style.opacity="",i&&(i.style.opacity=""),y(e,"prev")})}},{key:"stopSlideVideo",value:function(e){v.isNumber(e)&&(e=this.slidesContainer.querySelectorAll(".gslide")[e]);var t=e?e.querySelector(".gvideo"):null;if(!t)return!1;var i=t.id;if(c&&c.hasOwnProperty(i)){var n=c[i];b(t,"vimeo-video")&&n.pause(),b(t,"youtube-video")&&n.pauseVideo(),b(t,"jw-video")&&n.pause(!0),b(t,"html5-video")&&n.pause()}}},{key:"playSlideVideo",value:function(e){v.isNumber(e)&&(e=this.slidesContainer.querySelectorAll(".gslide")[e]);var t=e.querySelector(".gvideo");if(!t)return!1;var i=t.id;return c&&(v.has(c,i)||b(t,"wait-autoplay"))?(q(function(){return b(t,"iframe-ready")&&v.has(c,i)},function(){var e=c[i];b(t,"vimeo-video")&&q(function(){return e.play},function(){e.play()}),b(t,"youtube-video")&&q(function(){return e.playVideo},function(){e.playVideo()}),b(t,"jw-video")&&q(function(){return e.play},function(){e.play()}),b(t,"html5-video")&&e.play(),setTimeout(function(){y(t,"wait-autoplay")},300)},50,4e3),!1):void 0}},{key:"setElements",value:function(e){this.settings.elements=e}},{key:"getElements",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(this.elements=[],!v.isNil(this.settings.elements)&&v.isArray(this.settings.elements))return this.settings.elements;var t=!1;if(null!==e){var i=e.getAttribute("data-gallery");i&&""!==i&&(t=document.querySelectorAll('[data-gallery="'+i+'"]'))}return 0==t&&(t=document.querySelectorAll("."+this.settings.selector)),t=Array.prototype.slice.call(t)}},{key:"getActiveSlide",value:function(){return this.slidesContainer.querySelectorAll(".gslide")[this.index]}},{key:"getActiveSlideIndex",value:function(){return this.index}},{key:"getAnimationClasses",value:function(){var e=[];for(var t in this.settings.cssEfects)if(this.settings.cssEfects.hasOwnProperty(t)){var i=this.settings.cssEfects[t];e.push("g"+i.in),e.push("g"+i.out)}return e.join(" ")}},{key:"build",value:function(){var e=this;if(this.built)return!1;var t=S(this.settings.lightboxHtml);document.body.appendChild(t);var i=document.getElementById("glightbox-body");this.modal=i;var n=i.querySelector(".gclose");this.prevButton=i.querySelector(".gprev"),this.nextButton=i.querySelector(".gnext"),this.overlay=i.querySelector(".goverlay"),this.loader=i.querySelector(".gloader"),this.slidesContainer=document.getElementById("glightbox-slider"),this.events={},m(this.modal,"glightbox-"+this.settings.skin),this.settings.closeButton&&n&&(this.events.close=p("click",{onElement:n,withCallback:function(t,i){t.preventDefault(),e.close()}})),n&&!this.settings.closeButton&&n.parentNode.removeChild(n),this.nextButton&&(this.events.next=p("click",{onElement:this.nextButton,withCallback:function(t,i){t.preventDefault(),e.nextSlide()}})),this.prevButton&&(this.events.prev=p("click",{onElement:this.prevButton,withCallback:function(t,i){t.preventDefault(),e.prevSlide()}})),this.settings.closeOnOutsideClick&&(this.events.outClose=p("click",{onElement:i,withCallback:function(t,i){x(t.target,".ginner-container")||b(t.target,"gnext")||b(t.target,"gprev")||e.close()}})),f(this.elements,function(){var t=S(e.settings.slideHtml);e.slidesContainer.appendChild(t)}),s&&m(o,"glightbox-touch"),this.built=!0}},{key:"reload",value:function(){this.init()}},{key:"close",value:function(){var e=this;if(this.closing)return!1;this.closing=!0,this.stopSlideVideo(this.activeSlide),m(this.modal,"glightbox-closing"),w(this.overlay,"none"==this.settings.openEffect?"none":this.settings.cssEfects.fade.out),w(this.activeSlide,this.settings.closeEffect,function(){if(e.activeSlide=null,e.prevActiveSlideIndex=null,e.prevActiveSlide=null,e.built=!1,e.events)for(var t in e.events)e.events.hasOwnProperty(t)&&e.events[t].destroy();var i=document.body;y(i,"glightbox-open"),y(o,"glightbox-open"),y(i,"touching"),y(i,"gdesc-open"),i.style.width="",e.modal.parentNode.removeChild(e.modal),v.isFunction(e.settings.onClose)&&e.settings.onClose(),e.closing=null})}},{key:"destroy",value:function(){this.close(),this.baseEvents.destroy()}}]),e}();e.exports=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new F(e);return t.init(),t}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).GLightbox=e()}(this,function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function n(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}function s(t){return function(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function o(t){return Math.sqrt(t.x*t.x+t.y*t.y)}function l(t,e){var i=function(t,e){var i=o(t)*o(e);if(0===i)return 0;var n=function(t,e){return t.x*e.x+t.y*e.y}(t,e)/i;return n>1&&(n=1),Math.acos(n)}(t,e);return function(t,e){return t.x*e.y-e.x*t.y}(t,e)>0&&(i*=-1),180*i/Math.PI}var r=function(){function t(i){e(this,t),this.handlers=[],this.el=i}return n(t,[{key:"add",value:function(t){this.handlers.push(t)}},{key:"del",value:function(t){t||(this.handlers=[]);for(var e=this.handlers.length;e>=0;e--)this.handlers[e]===t&&this.handlers.splice(e,1)}},{key:"dispatch",value:function(){for(var t=0,e=this.handlers.length;t<e;t++){var i=this.handlers[t];"function"==typeof i&&i.apply(this.el,arguments)}}}]),t}();function a(t,e){var i=new r(t);return i.add(e),i}var c=function(){function t(i,n){e(this,t),this.element="string"==typeof i?document.querySelector(i):i,this.start=this.start.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.cancel=this.cancel.bind(this),this.element.addEventListener("touchstart",this.start,!1),this.element.addEventListener("touchmove",this.move,!1),this.element.addEventListener("touchend",this.end,!1),this.element.addEventListener("touchcancel",this.cancel,!1),this.preV={x:null,y:null},this.pinchStartLen=null,this.zoom=1,this.isDoubleTap=!1;var s=function(){};this.rotate=a(this.element,n.rotate||s),this.touchStart=a(this.element,n.touchStart||s),this.multipointStart=a(this.element,n.multipointStart||s),this.multipointEnd=a(this.element,n.multipointEnd||s),this.pinch=a(this.element,n.pinch||s),this.swipe=a(this.element,n.swipe||s),this.tap=a(this.element,n.tap||s),this.doubleTap=a(this.element,n.doubleTap||s),this.longTap=a(this.element,n.longTap||s),this.singleTap=a(this.element,n.singleTap||s),this.pressMove=a(this.element,n.pressMove||s),this.twoFingerPressMove=a(this.element,n.twoFingerPressMove||s),this.touchMove=a(this.element,n.touchMove||s),this.touchEnd=a(this.element,n.touchEnd||s),this.touchCancel=a(this.element,n.touchCancel||s),this._cancelAllHandler=this.cancelAll.bind(this),window.addEventListener("scroll",this._cancelAllHandler),this.delta=null,this.last=null,this.now=null,this.tapTimeout=null,this.singleTapTimeout=null,this.longTapTimeout=null,this.swipeTimeout=null,this.x1=this.x2=this.y1=this.y2=null,this.preTapPosition={x:null,y:null}}return n(t,[{key:"start",value:function(t){if(t.touches){this.now=Date.now(),this.x1=t.touches[0].pageX,this.y1=t.touches[0].pageY,this.delta=this.now-(this.last||this.now),this.touchStart.dispatch(t,this.element),null!==this.preTapPosition.x&&(this.isDoubleTap=this.delta>0&&this.delta<=250&&Math.abs(this.preTapPosition.x-this.x1)<30&&Math.abs(this.preTapPosition.y-this.y1)<30,this.isDoubleTap&&clearTimeout(this.singleTapTimeout)),this.preTapPosition.x=this.x1,this.preTapPosition.y=this.y1,this.last=this.now;var e=this.preV;if(t.touches.length>1){this._cancelLongTap(),this._cancelSingleTap();var i={x:t.touches[1].pageX-this.x1,y:t.touches[1].pageY-this.y1};e.x=i.x,e.y=i.y,this.pinchStartLen=o(e),this.multipointStart.dispatch(t,this.element)}this._preventTap=!1,this.longTapTimeout=setTimeout(function(){this.longTap.dispatch(t,this.element),this._preventTap=!0}.bind(this),750)}}},{key:"move",value:function(t){if(t.touches){var e=this.preV,i=t.touches.length,n=t.touches[0].pageX,s=t.touches[0].pageY;if(this.isDoubleTap=!1,i>1){var r=t.touches[1].pageX,a=t.touches[1].pageY,c={x:t.touches[1].pageX-n,y:t.touches[1].pageY-s};null!==e.x&&(this.pinchStartLen>0&&(t.zoom=o(c)/this.pinchStartLen,this.pinch.dispatch(t,this.element)),t.angle=l(c,e),this.rotate.dispatch(t,this.element)),e.x=c.x,e.y=c.y,null!==this.x2&&null!==this.sx2?(t.deltaX=(n-this.x2+r-this.sx2)/2,t.deltaY=(s-this.y2+a-this.sy2)/2):(t.deltaX=0,t.deltaY=0),this.twoFingerPressMove.dispatch(t,this.element),this.sx2=r,this.sy2=a}else{if(null!==this.x2){t.deltaX=n-this.x2,t.deltaY=s-this.y2;var h=Math.abs(this.x1-this.x2),u=Math.abs(this.y1-this.y2);(h>10||u>10)&&(this._preventTap=!0)}else t.deltaX=0,t.deltaY=0;this.pressMove.dispatch(t,this.element)}this.touchMove.dispatch(t,this.element),this._cancelLongTap(),this.x2=n,this.y2=s,i>1&&t.preventDefault()}}},{key:"end",value:function(t){if(t.changedTouches){this._cancelLongTap();var e=this;t.touches.length<2&&(this.multipointEnd.dispatch(t,this.element),this.sx2=this.sy2=null),this.x2&&Math.abs(this.x1-this.x2)>30||this.y2&&Math.abs(this.y1-this.y2)>30?(t.direction=this._swipeDirection(this.x1,this.x2,this.y1,this.y2),this.swipeTimeout=setTimeout(function(){e.swipe.dispatch(t,e.element)},0)):(this.tapTimeout=setTimeout(function(){e._preventTap||e.tap.dispatch(t,e.element),e.isDoubleTap&&(e.doubleTap.dispatch(t,e.element),e.isDoubleTap=!1)},0),e.isDoubleTap||(e.singleTapTimeout=setTimeout(function(){e.singleTap.dispatch(t,e.element)},250))),this.touchEnd.dispatch(t,this.element),this.preV.x=0,this.preV.y=0,this.zoom=1,this.pinchStartLen=null,this.x1=this.x2=this.y1=this.y2=null}}},{key:"cancelAll",value:function(){this._preventTap=!0,clearTimeout(this.singleTapTimeout),clearTimeout(this.tapTimeout),clearTimeout(this.longTapTimeout),clearTimeout(this.swipeTimeout)}},{key:"cancel",value:function(t){this.cancelAll(),this.touchCancel.dispatch(t,this.element)}},{key:"_cancelLongTap",value:function(){clearTimeout(this.longTapTimeout)}},{key:"_cancelSingleTap",value:function(){clearTimeout(this.singleTapTimeout)}},{key:"_swipeDirection",value:function(t,e,i,n){return Math.abs(t-e)>=Math.abs(i-n)?t-e>0?"Left":"Right":i-n>0?"Up":"Down"}},{key:"on",value:function(t,e){this[t]&&this[t].add(e)}},{key:"off",value:function(t,e){this[t]&&this[t].del(e)}},{key:"destroy",value:function(){return this.singleTapTimeout&&clearTimeout(this.singleTapTimeout),this.tapTimeout&&clearTimeout(this.tapTimeout),this.longTapTimeout&&clearTimeout(this.longTapTimeout),this.swipeTimeout&&clearTimeout(this.swipeTimeout),this.element.removeEventListener("touchstart",this.start),this.element.removeEventListener("touchmove",this.move),this.element.removeEventListener("touchend",this.end),this.element.removeEventListener("touchcancel",this.cancel),this.rotate.del(),this.touchStart.del(),this.multipointStart.del(),this.multipointEnd.del(),this.pinch.del(),this.swipe.del(),this.tap.del(),this.doubleTap.del(),this.longTap.del(),this.singleTap.del(),this.pressMove.del(),this.twoFingerPressMove.del(),this.touchMove.del(),this.touchEnd.del(),this.touchCancel.del(),this.preV=this.pinchStartLen=this.zoom=this.isDoubleTap=this.delta=this.last=this.now=this.tapTimeout=this.singleTapTimeout=this.longTapTimeout=this.swipeTimeout=this.x1=this.x2=this.y1=this.y2=this.preTapPosition=this.rotate=this.touchStart=this.multipointStart=this.multipointEnd=this.pinch=this.swipe=this.tap=this.doubleTap=this.longTap=this.singleTap=this.pressMove=this.touchMove=this.touchEnd=this.touchCancel=this.twoFingerPressMove=null,window.removeEventListener("scroll",this._cancelAllHandler),null}}]),t}(),h=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i),u=null!==h||void 0!==document.createTouch||"ontouchstart"in window||"onmsgesturechange"in window||navigator.msMaxTouchPoints,d=document.getElementsByTagName("html")[0],p=function(){var t,e=document.createElement("fakeelement"),i={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(t in i)if(void 0!==e.style[t])return i[t]}(),v=function(){var t,e=document.createElement("fakeelement"),i={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(t in i)if(void 0!==e.style[t])return i[t]}(),f=Date.now(),g={},m={selector:"glightbox",elements:null,skin:"clean",closeButton:!0,startAt:null,autoplayVideos:!0,descPosition:"bottom",width:900,height:506,videosWidth:960,beforeSlideChange:null,afterSlideChange:null,beforeSlideLoad:null,afterSlideLoad:null,onOpen:null,onClose:null,loopAtEnd:!1,touchNavigation:!0,keyboardNavigation:!0,closeOnOutsideClick:!0,plyr:{css:"https://cdn.plyr.io/3.5.6/plyr.css",js:"https://cdn.plyr.io/3.5.6/plyr.js",config:{youtube:{noCookie:!0,rel:0,showinfo:0,iv_load_policy:3},vimeo:{byline:!1,portrait:!1,title:!1,transparent:!1}}},openEffect:"zoomIn",closeEffect:"zoomOut",slideEffect:"slide",moreText:"See more",moreLength:60,lightboxHtml:"",cssEfects:{fade:{in:"fadeIn",out:"fadeOut"},zoom:{in:"zoomIn",out:"zoomOut"},slide:{in:"slideInRight",out:"slideOutLeft"},slide_back:{in:"slideInLeft",out:"slideOutRight"}}};m.slideHtml='<div class="gslide"> <div class="gslide-inner-content"> <div class="ginner-container"> <div class="gslide-media"> </div> <div class="gslide-description"> <div class="gdesc-inner"> <h4 class="gslide-title"></h4> <div class="gslide-desc"></div> </div> </div> </div> </div> </div>';function y(){var t={},e=!1,i=0,n=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(e=arguments[0],i++);for(var s=function(i){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e&&"[object Object]"===Object.prototype.toString.call(i[n])?t[n]=y(!0,t[n],i[n]):t[n]=i[n])};i<n;i++){s(arguments[i])}return t}m.lightboxHtml='<div id="glightbox-body" class="glightbox-container"> <div class="gloader visible"></div> <div class="goverlay"></div> <div class="gcontainer"> <div id="glightbox-slider" class="gslider"></div> <button class="gnext gbtn" tabindex="0"></button> <button class="gprev gbtn" tabindex="1"></button> <button class="gclose gbtn" tabindex="2"></button> </div> </div>';var b={isFunction:function(t){return"function"==typeof t},isString:function(t){return"string"==typeof t},isNode:function(t){return!(!t||!t.nodeType||1!=t.nodeType)},isArray:function(t){return Array.isArray(t)},isArrayLike:function(t){return t&&t.length&&isFinite(t.length)},isObject:function(e){return"object"===t(e)&&null!=e&&!b.isFunction(e)&&!b.isArray(e)},isNil:function(t){return null==t},has:function(t,e){return null!==t&&hasOwnProperty.call(t,e)},size:function(t){if(b.isObject(t)){if(t.keys)return t.keys().length;var e=0;for(var i in t)b.has(t,i)&&e++;return e}return t.length},isNumber:function(t){return!isNaN(parseFloat(t))&&isFinite(t)}};function x(t,e){if((b.isNode(t)||t===window||t===document)&&(t=[t]),b.isArrayLike(t)||b.isObject(t)||(t=[t]),0!=b.size(t))if(b.isArrayLike(t)&&!b.isObject(t))for(var i=t.length,n=0;n<i&&!1!==e.call(t[n],t[n],n,t);n++);else if(b.isObject(t))for(var s in t)if(b.has(t,s)&&!1===e.call(t[s],t[s],s,t))break}function T(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=t[f]=t[f]||[],s={all:n,evt:null,found:null};return e&&i&&b.size(n)>0&&x(n,function(t,n){if(t.eventName==e&&t.fn.toString()==i.toString())return s.found=!0,s.evt=n,!1}),s}function S(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=e.onElement,n=e.withCallback,s=e.avoidDuplicate,o=void 0===s||s,l=e.once,r=void 0!==l&&l,a=e.useCapture,c=void 0!==a&&a,h=arguments.length>2?arguments[2]:void 0,u=i||[];function d(t){b.isFunction(n)&&n.call(h,t,this),r&&d.destroy()}return b.isString(u)&&(u=document.querySelectorAll(u)),d.destroy=function(){x(u,function(e){var i=T(e,t,d);i.found&&i.all.splice(i.evt,1),e.removeEventListener&&e.removeEventListener(t,d,c)})},x(u,function(e){var i=T(e,t,d);(e.addEventListener&&o&&!i.found||!o)&&(e.addEventListener(t,d,c),i.all.push({eventName:t,fn:d}))}),d}function w(t,e){x(e.split(" "),function(e){return t.classList.add(e)})}function k(t,e){x(e.split(" "),function(e){return t.classList.remove(e)})}function E(t,e){return t.classList.contains(e)}function A(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!t||""===e)return!1;if("none"==e)return b.isFunction(i)&&i(),!1;var n=e.split(" ");x(n,function(e){w(t,"g"+e)}),S(v,{onElement:t,avoidDuplicate:!1,once:!0,withCallback:function(t,e){x(n,function(t){k(e,"g"+t)}),b.isFunction(i)&&i()}})}function C(t){var e=document.createDocumentFragment(),i=document.createElement("div");for(i.innerHTML=t;i.firstChild;)e.appendChild(i.firstChild);return e}function L(t,e){for(;t!==document.body;){if("function"==typeof(t=t.parentElement).matches?t.matches(e):t.msMatchesSelector(e))return t}}function M(t){t.style.display="block"}function O(t){t.style.display="none"}var q=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1?arguments[1]:void 0,i={href:"",title:"",type:"",description:"",descPosition:"bottom",effect:"",width:"",height:"",node:t};if(b.isObject(t)&&!b.isNode(t))return y(i,t);var n="",s=t.getAttribute("data-glightbox"),o=t.nodeName.toLowerCase();if("a"===o&&(n=t.href),"img"===o&&(n=t.src),i.href=n,x(i,function(n,s){b.has(e,s)&&(i[s]=e[s]);var o=t.dataset[s];b.isNil(o)||(i[s]=o)}),i.type||(i.type=D(n)),b.isNil(s)){if("a"==o){var l=t.title;b.isNil(l)||""===l||(i.title=l)}if("img"==o){var r=t.alt;b.isNil(r)||""===r||(i.title=r)}var a=t.getAttribute("data-description");b.isNil(a)||""===a||(i.description=a)}else{var c=[];x(i,function(t,e){c.push(";\\s?"+e)}),c=c.join("\\s?:|"),""!==s.trim()&&x(i,function(t,e){var n=s,o=new RegExp("s?"+e+"s?:s?(.*?)("+c+"s?:|$)"),l=n.match(o);if(l&&l.length&&l[1]){var r=l[1].trim().replace(/;\s*$/,"");i[e]=r}})}var h=t.querySelector(".glightbox-desc");h&&(i.description=h.innerHTML);var u="video"==i.type?e.videosWidth:e.width,d=e.height;return i.width=b.has(i,"width")?i.width:u,i.height=b.has(i,"height")?i.height:d,i},N=function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(E(e,"loaded"))return!1;b.isFunction(this.settings.beforeSlideLoad)&&this.settings.beforeSlideLoad(e,i);var s=i.type,o=i.descPosition,l=e.querySelector(".gslide-media"),r=e.querySelector(".gslide-title"),a=e.querySelector(".gslide-desc"),c=e.querySelector(".gdesc-inner"),u=n;if(b.isFunction(this.settings.afterSlideLoad)&&(u=function(){b.isFunction(n)&&n(),t.settings.afterSlideLoad(e,i)}),""==i.title&&""==i.description?c&&c.parentNode.parentNode.removeChild(c.parentNode):(r&&""!==i.title?r.innerHTML=i.title:r.parentNode.removeChild(r),a&&""!==i.description?h&&this.settings.moreLength>0?(i.smallDescription=Y(i.description,this.settings.moreLength,this.settings.moreText),a.innerHTML=i.smallDescription,W.apply(this,[a,i])):a.innerHTML=i.description:a.parentNode.removeChild(a),w(l.parentNode,"desc-".concat(o)),w(c.parentNode,"description-".concat(o))),w(l,"gslide-".concat(s)),w(e,"loaded"),"video"===s)return l.innerHTML='<div class="gvideo-wrapper"></div>',void F.apply(this,[e,i,u]);if("external"===s){var d=I({url:i.href,width:i.width,height:i.height,callback:u});return l.parentNode.style.maxWidth="".concat(i.width,"px"),void l.appendChild(d)}if("inline"!==s){if("image"===s){var p=new Image;return p.addEventListener("load",function(){b.isFunction(u)&&u()},!1),p.src=i.href,void l.appendChild(p)}b.isFunction(u)&&u()}else j.apply(this,[e,i,u])};function F(t,e,i){var n=this,s="gvideo"+e.index,o=t.querySelector(".gvideo-wrapper");P(this.settings.plyr.css);var l=e.href,r=location.protocol.replace(":",""),a="",c="",h=!1;"file"==r&&(r="http"),o.parentNode.style.maxWidth="".concat(e.width,"px"),P(this.settings.plyr.js,"Plyr",function(){if(l.match(/vimeo\.com\/([0-9]*)/)){var t=/vimeo.*\/(\d+)/i.exec(l);a="vimeo",c=t[1]}if(l.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||l.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)){var r=function(t){var e="";e=void 0!==(t=t.replace(/(>|<)/gi,"").split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/))[2]?(e=t[2].split(/[^0-9a-z_\-]/i))[0]:t;return e}(l);a="youtube",c=r}if(null!==l.match(/\.(mp4|ogg|webm)$/)){a="local";var u='<video id="'+s+'" ';u+='style="background:#000; max-width: '.concat(e.width,'px;" '),u+='preload="metadata" ',u+='x-webkit-airplay="allow" ',u+='webkit-playsinline="" ',u+="controls ",u+='class="gvideo-local">';var d=l.toLowerCase().split(".").pop(),p={mp4:"",ogg:"",webm:""};for(var v in p[d]=l,p)if(p.hasOwnProperty(v)){var f=p[v];e.hasOwnProperty(v)&&(f=e[v]),""!==f&&(u+='<source src="'.concat(f,'" type="video/').concat(v,'">'))}h=C(u+="</video>")}var m=h||C('<div id="'.concat(s,'" data-plyr-provider="').concat(a,'" data-plyr-embed-id="').concat(c,'"></div>'));w(o,"".concat(a,"-video gvideo")),o.appendChild(m),o.setAttribute("data-id",s);var y=b.has(n.settings.plyr,"config")?n.settings.plyr.config:{};new Plyr("#"+s,y).on("ready",function(t){var e=t.detail.plyr;g[s]=e,b.isFunction(i)&&i()})})}function I(t){var e=t.url,i=t.width,n=t.height,s=t.allow,o=t.callback,l=t.appendTo,r=document.createElement("iframe"),a=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;return r.className="vimeo-video gvideo",r.src=e,n&&(r.style.height=h&&a<767?"":"".concat(n,"px")),i&&(r.style.width="".concat(i,"px")),s&&r.setAttribute("allow",s),r.onload=function(){w(r,"node-ready"),b.isFunction(o)&&o()},l&&l.appendChild(r),r}function P(t,e,i){if(b.isNil(t))console.error("Inject videos api error");else{var n;if(b.isFunction(e)&&(i=e,e=!1),-1!==t.indexOf(".css")){if((n=document.querySelectorAll('link[href="'+t+'"]'))&&n.length>0)return void(b.isFunction(i)&&i());var s=document.getElementsByTagName("head")[0],o=s.querySelectorAll('link[rel="stylesheet"]'),l=document.createElement("link");return l.rel="stylesheet",l.type="text/css",l.href=t,l.media="all",o?s.insertBefore(l,o[0]):s.appendChild(l),void(b.isFunction(i)&&i())}if((n=document.querySelectorAll('script[src="'+t+'"]'))&&n.length>0){if(b.isFunction(i)){if(b.isString(e))return B(function(){return void 0!==window[e]},function(){i()}),!1;i()}}else{var r=document.createElement("script");r.type="text/javascript",r.src=t,r.onload=function(){if(b.isFunction(i)){if(b.isString(e))return B(function(){return void 0!==window[e]},function(){i()}),!1;i()}},document.body.appendChild(r)}}}function B(t,e,i,n){if(t())e();else{var s;i||(i=100);var o=setInterval(function(){t()&&(clearInterval(o),s&&clearTimeout(s),e())},i);n&&(s=setTimeout(function(){clearInterval(o)},n))}}function j(t,e,i){var n=this,s=t.querySelector(".gslide-media"),o=e.href.split("#").pop().trim(),l=document.getElementById(o);if(!l)return!1;var r=l.cloneNode(!0);r.style.height=b.isNumber(e.height)?"".concat(e.height,"px"):e.height,r.style.maxWidth=b.isNumber(e.width)?"".concat(e.width,"px"):e.width,w(r,"ginlined-content"),s.appendChild(r),this.events["inlineclose"+o]=S("click",{onElement:s.querySelectorAll(".gtrigger-close"),withCallback:function(t){t.preventDefault(),n.close()}}),b.isFunction(i)&&i()}var D=function(t){var e=t;if(null!==(t=t.toLowerCase()).match(/\.(jpeg|jpg|gif|png|apn|webp|svg)$/))return"image";if(t.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||t.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/))return"video";if(t.match(/vimeo\.com\/([0-9]*)/))return"video";if(null!==t.match(/\.(mp4|ogg|webm)$/))return"video";if(t.indexOf("#")>-1&&""!==e.split("#").pop().trim())return"inline";return t.includes("gajax=true")?"ajax":"external"};function _(){var t=this;if(this.events.hasOwnProperty("keyboard"))return!1;this.events.keyboard=S("keydown",{onElement:window,withCallback:function(e,i){var n=(e=e||window.event).keyCode;if(9==n){e.preventDefault();var o=document.querySelectorAll(".gbtn");if(!o||o.length<=0)return;var l=s(o).filter(function(t){return E(t,"focused")});if(!l.length){var r=document.querySelector('.gbtn[tabindex="0"]');return void(r&&(r.focus(),w(r,"focused")))}o.forEach(function(t){return k(t,"focused")});var a=l[0].getAttribute("tabindex");a=a||"0";var c=parseInt(a)+1;c>o.length-1&&(c="0");var h=document.querySelector('.gbtn[tabindex="'.concat(c,'"]'));h&&(h.focus(),w(h,"focused"))}39==n&&t.nextSlide(),37==n&&t.prevSlide(),27==n&&t.close()}})}function z(){var t=this;if(this.events.hasOwnProperty("touch"))return!1;var e,i,n,s=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,o=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,l=null,r=null,a=null,h=!1,u=1,d=1,p=!1,v=!1,f=null,g=null,m=null,y=null,b=0,x=0,T=!1,S=!1,A={},C={},L=0,M=0,O=this,q=document.getElementById("glightbox-slider"),N=document.querySelector(".goverlay"),F=new c(q,{touchStart:function(t){C=t.targetTouches[0],A.pageX=t.targetTouches[0].pageX,A.pageY=t.targetTouches[0].pageY,L=t.targetTouches[0].clientX,M=t.targetTouches[0].clientY,l=O.activeSlide,r=l.querySelector(".gslide-media"),n=l.querySelector(".gslide-inline"),a=null,E(r,"gslide-image")&&(a=r.querySelector("img")),k(N,"greset")},touchMove:function(t){if(C=t.targetTouches[0],!p&&!v){if(n&&n.offsetHeight>o){var l=A.pageX-C.pageX;if(Math.abs(l)<=13)return!1}h=!0;var c,u=t.targetTouches[0].clientX,d=t.targetTouches[0].clientY,f=L-u,g=M-d;if(Math.abs(f)>Math.abs(g)?(T=!1,S=!0):(S=!1,T=!0),e=C.pageX-A.pageX,b=100*e/s,i=C.pageY-A.pageY,x=100*i/o,T&&a&&(c=1-Math.abs(i)/o,N.style.opacity=c),S&&(c=1-Math.abs(e)/s,r.style.opacity=c),!a)return H(r,"translate3d(".concat(b,"%, 0, 0)"));H(r,"translate3d(".concat(b,"%, ").concat(x,"%, 0)"))}},touchEnd:function(){if(h=!1,v||p)return m=f,void(y=g);var e=Math.abs(parseInt(x)),i=Math.abs(parseInt(b));if(!(e>35&&a))return e<35&&i<25?(w(N,"greset"),N.style.opacity=1,X(r)):void 0;t.close()},multipointEnd:function(){setTimeout(function(){p=!1},50)},multipointStart:function(){p=!0,u=d||1},pinch:function(t){if(!a||h)return!1;p=!0,a.scaleX=a.scaleY=u*t.zoom;var e=u*t.zoom;if(v=!0,e<=1)return v=!1,e=1,y=null,m=null,f=null,g=null,void a.setAttribute("style","");e>4.5&&(e=4.5),a.style.transform="scale3d(".concat(e,", ").concat(e,", 1)"),d=e},pressMove:function(t){if(v&&!p){var e=C.pageX-A.pageX,i=C.pageY-A.pageY;m&&(e+=m),y&&(i+=y),f=e,g=i;var n="translate3d(".concat(e,"px, ").concat(i,"px, 0)");d&&(n+=" scale3d(".concat(d,", ").concat(d,", 1)")),H(a,n)}},swipe:function(e){if(!v)if(p)p=!1;else{if("Left"==e.direction){if(t.index==t.elements.length-1)return X(r);t.nextSlide()}if("Right"==e.direction){if(0==t.index)return X(r);t.prevSlide()}}}});this.events.touch=F}function H(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(""==e)return t.style.webkitTransform="",t.style.MozTransform="",t.style.msTransform="",t.style.OTransform="",t.style.transform="",!1;t.style.webkitTransform=e,t.style.MozTransform=e,t.style.msTransform=e,t.style.OTransform=e,t.style.transform=e}function X(t){var e=E(t,"gslide-media")?t:t.querySelector(".gslide-media"),i=t.querySelector(".gslide-description");w(e,"greset"),H(e,"translate3d(0, 0, 0)");S(p,{onElement:e,once:!0,withCallback:function(t,i){k(e,"greset")}});e.style.opacity="",i&&(i.style.opacity="")}function Y(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:50,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=i;if((t=t.trim()).length<=e)return t;var s=t.substr(0,e-1);return n?s+'... <a href="#" class="desc-more">'+i+"</a>":s}function W(t,e){var i=t.querySelector(".desc-more");if(!i)return!1;S("click",{onElement:i,withCallback:function(t,i){t.preventDefault();var n=document.body,s=L(i,".gslide-desc");if(!s)return!1;s.innerHTML=e.description,w(n,"gdesc-open");var o=S("click",{onElement:[n,L(s,".gslide-description")],withCallback:function(t,i){"a"!==t.target.nodeName.toLowerCase()&&(k(n,"gdesc-open"),w(n,"gdesc-closed"),s.innerHTML=e.smallDescription,W(s,e),setTimeout(function(){k(n,"gdesc-closed")},400),o.destroy())}})}})}var V=function(){function t(i){e(this,t),this.settings=y(m,i||{}),this.effectsClasses=this.getAnimationClasses()}return n(t,[{key:"init",value:function(){var t=this;this.baseEvents=S("click",{onElement:".".concat(this.settings.selector),withCallback:function(e,i){e.preventDefault(),t.open(i)}})}},{key:"open",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(this.elements=this.getElements(t),0==this.elements.length)return!1;this.activeSlide=null,this.prevActiveSlideIndex=null,this.prevActiveSlide=null;var e=this.settings.startAt;t&&b.isNil(e)&&(e=this.elements.indexOf(t))<0&&(e=0),b.isNil(e)&&(e=0),this.build(),A(this.overlay,"none"==this.settings.openEffect?"none":this.settings.cssEfects.fade.in);var i=document.body;if(i.style.width="".concat(i.offsetWidth,"px"),w(i,"glightbox-open"),w(d,"glightbox-open"),h&&(w(d,"glightbox-mobile"),this.settings.slideEffect="slide"),this.showSlide(e,!0),1==this.elements.length?(O(this.prevButton),O(this.nextButton)):(M(this.prevButton),M(this.nextButton)),this.lightboxOpen=!0,b.isFunction(this.settings.onOpen)&&this.settings.onOpen(),h&&u&&this.settings.touchNavigation)return z.apply(this),!1;this.settings.keyboardNavigation&&_.apply(this)}},{key:"showSlide",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];M(this.loader),this.index=parseInt(e);var n=this.slidesContainer.querySelector(".current");n&&k(n,"current"),this.slideAnimateOut();var s=this.slidesContainer.querySelectorAll(".gslide")[e];if(M(this.slidesContainer),E(s,"loaded"))this.slideAnimateIn(s,i),O(this.loader);else{M(this.loader);var o=q(this.elements[e],this.settings);o.index=e,N.apply(this,[s,o,function(){O(t.loader),t.slideAnimateIn(s,i)}])}this.preloadSlide(e+1),this.preloadSlide(e-1),k(this.nextButton,"disabled"),k(this.prevButton,"disabled"),0===e?w(this.prevButton,"disabled"):e===this.elements.length-1&&!0!==this.settings.loopAtEnd&&w(this.nextButton,"disabled"),this.activeSlide=s}},{key:"preloadSlide",value:function(t){var e=this;if(t<0||t>this.elements.length)return!1;if(b.isNil(this.elements[t]))return!1;var i=this.slidesContainer.querySelectorAll(".gslide")[t];if(E(i,"loaded"))return!1;var n=q(this.elements[t],this.settings);n.index=t;var s=n.sourcetype;"video"==s||"external"==s?setTimeout(function(){N.apply(e,[i,n])},200):N.apply(this,[i,n])}},{key:"prevSlide",value:function(){var t=this.index-1;if(t<0)return!1;this.goToSlide(t)}},{key:"nextSlide",value:function(){var t=this.index+1;if(t>this.elements.length)return!1;this.goToSlide(t)}},{key:"goToSlide",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];t>-1&&(this.prevActiveSlide=this.activeSlide,this.prevActiveSlideIndex=this.index,t<this.elements.length?this.showSlide(t):!0===this.settings.loopAtEnd&&(t=0,this.showSlide(t)))}},{key:"slideAnimateIn",value:function(t,e){var i=this,n=t.querySelector(".gslide-media"),s=t.querySelector(".gslide-description"),o={index:this.prevActiveSlideIndex,slide:this.prevActiveSlide},l={index:this.index,slide:this.activeSlide};if(n.offsetWidth>0&&s&&(O(s),t.querySelector(".ginner-container").style.maxWidth="".concat(n.offsetWidth,"px"),s.style.display=""),k(t,this.effectsClasses),e)A(t,this.settings.openEffect,function(){!h&&i.settings.autoplayVideos&&i.playSlideVideo(t),b.isFunction(i.settings.afterSlideChange)&&i.settings.afterSlideChange.apply(i,[o,l])});else{var r=this.settings.slideEffect,a="none"!==r?this.settings.cssEfects[r].in:r;this.prevActiveSlideIndex>this.index&&"slide"==this.settings.slideEffect&&(a=this.settings.cssEfects.slide_back.in),A(t,a,function(){!h&&i.settings.autoplayVideos&&i.playSlideVideo(t),b.isFunction(i.settings.afterSlideChange)&&i.settings.afterSlideChange.apply(i,[o,l])})}w(t,"current")}},{key:"slideAnimateOut",value:function(){if(!this.prevActiveSlide)return!1;var t=this.prevActiveSlide;k(t,this.effectsClasses),w(t,"prev");var e=this.settings.slideEffect,i="none"!==e?this.settings.cssEfects[e].out:e;this.stopSlideVideo(t),b.isFunction(this.settings.beforeSlideChange)&&this.settings.beforeSlideChange.apply(this,[{index:this.prevActiveSlideIndex,slide:this.prevActiveSlide},{index:this.index,slide:this.activeSlide}]),this.prevActiveSlideIndex>this.index&&"slide"==this.settings.slideEffect&&(i=this.settings.cssEfects.slide_back.out),A(t,i,function(){var e=t.querySelector(".gslide-media"),i=t.querySelector(".gslide-description");e.style.transform="",k(e,"greset"),e.style.opacity="",i&&(i.style.opacity=""),k(t,"prev")})}},{key:"stopSlideVideo",value:function(t){b.isNumber(t)&&(t=this.slidesContainer.querySelectorAll(".gslide")[t]);var e=t?t.querySelector(".gvideo"):null;if(!e)return!1;var i=e.getAttribute("data-id");if(g&&b.has(g,i)){var n=g[i];n&&n.play&&n.pause()}}},{key:"playSlideVideo",value:function(t){b.isNumber(t)&&(t=this.slidesContainer.querySelectorAll(".gslide")[t]);var e=t.querySelector(".gvideo");if(!e)return!1;var i=e.getAttribute("data-id");if(g&&b.has(g,i)){var n=g[i];n&&n.play&&n.play()}}},{key:"setElements",value:function(t){this.settings.elements=t}},{key:"getElements",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(this.elements=[],!b.isNil(this.settings.elements)&&b.isArray(this.settings.elements))return this.settings.elements;var e=!1;if(null!==t){var i=t.getAttribute("data-gallery");i&&""!==i&&(e=document.querySelectorAll('[data-gallery="'.concat(i,'"]')))}return 0==e&&(e=document.querySelectorAll(".".concat(this.settings.selector))),e=Array.prototype.slice.call(e)}},{key:"getActiveSlide",value:function(){return this.slidesContainer.querySelectorAll(".gslide")[this.index]}},{key:"getActiveSlideIndex",value:function(){return this.index}},{key:"getAnimationClasses",value:function(){var t=[];for(var e in this.settings.cssEfects)if(this.settings.cssEfects.hasOwnProperty(e)){var i=this.settings.cssEfects[e];t.push("g".concat(i.in)),t.push("g".concat(i.out))}return t.join(" ")}},{key:"build",value:function(){var t=this;if(this.built)return!1;var e=C(this.settings.lightboxHtml);document.body.appendChild(e);var i=document.getElementById("glightbox-body");this.modal=i;var n=i.querySelector(".gclose");this.prevButton=i.querySelector(".gprev"),this.nextButton=i.querySelector(".gnext"),this.overlay=i.querySelector(".goverlay"),this.loader=i.querySelector(".gloader"),this.slidesContainer=document.getElementById("glightbox-slider"),this.events={},w(this.modal,"glightbox-"+this.settings.skin),this.settings.closeButton&&n&&(this.events.close=S("click",{onElement:n,withCallback:function(e,i){e.preventDefault(),t.close()}})),n&&!this.settings.closeButton&&n.parentNode.removeChild(n),this.nextButton&&(this.events.next=S("click",{onElement:this.nextButton,withCallback:function(e,i){e.preventDefault(),t.nextSlide()}})),this.prevButton&&(this.events.prev=S("click",{onElement:this.prevButton,withCallback:function(e,i){e.preventDefault(),t.prevSlide()}})),this.settings.closeOnOutsideClick&&(this.events.outClose=S("click",{onElement:i,withCallback:function(e,i){L(e.target,".ginner-container")||E(e.target,"gnext")||E(e.target,"gprev")||t.close()}})),x(this.elements,function(){var e=C(t.settings.slideHtml);t.slidesContainer.appendChild(e)}),u&&w(d,"glightbox-touch"),this.built=!0}},{key:"reload",value:function(){this.init()}},{key:"close",value:function(){var t=this;if(this.closing)return!1;this.closing=!0,this.stopSlideVideo(this.activeSlide),w(this.modal,"glightbox-closing"),A(this.overlay,"none"==this.settings.openEffect?"none":this.settings.cssEfects.fade.out),A(this.activeSlide,this.settings.closeEffect,function(){if(t.activeSlide=null,t.prevActiveSlideIndex=null,t.prevActiveSlide=null,t.built=!1,t.events){for(var e in t.events)t.events.hasOwnProperty(e)&&t.events[e].destroy();t.events=null}var i=document.body;k(i,"glightbox-open"),k(d,"glightbox-open"),k(i,"touching"),k(i,"gdesc-open"),i.style.width="",t.modal.parentNode.removeChild(t.modal),b.isFunction(t.settings.onClose)&&t.settings.onClose(),t.closing=null})}},{key:"destroy",value:function(){this.close(),this.baseEvents.destroy()}}]),t}();return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=new V(t);return e.init(),e}}); |
{ | ||
"name": "glightbox", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Pure Javascript lightbox", | ||
"main": "dist/js/glightbox.min.js", | ||
"scripts": { | ||
"start": "gulp watch", | ||
"release": "gulp release" | ||
"watch": "node development/watcher.js" | ||
}, | ||
@@ -25,27 +24,33 @@ "author": "MC Studios", | ||
"devDependencies": { | ||
"babel-core": "^6.26.0", | ||
"babel-plugin-transform-es2015-modules-umd": "^6.24.1", | ||
"babel-preset-es2015": "^6.24.1", | ||
"css-mqpacker": "^6.0.1", | ||
"cssnano": "^3.10.0", | ||
"gulp": "github:gulpjs/gulp#v4.0.0-alpha.3", | ||
"gulp-babel": "^7.0.0", | ||
"gulp-cached": "^1.1.1", | ||
"gulp-cssmin": "^0.2.0", | ||
"gulp-notify": "^3.0.0", | ||
"gulp-plumber": "^1.1.0", | ||
"gulp-postcss": "^7.0.0", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-terser": "^1.1.6", | ||
"gulp-zip": "^4.1.0", | ||
"lost": "^8.2.0", | ||
"postcss-cssnext": "^3.0.2", | ||
"postcss-discard-empty": "^2.1.0", | ||
"postcss-fixes": "^2.0.1", | ||
"postcss-nested": "^2.1.2", | ||
"postcss-nesting": "^4.2.1", | ||
"@babel/cli": "^7.2.3", | ||
"@babel/core": "^7.2.2", | ||
"@babel/node": "^7.2.2", | ||
"@babel/preset-env": "^7.3.1", | ||
"@babel/register": "^7.0.0", | ||
"archiver": "^3.1.1", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"chokidar": "^3.0.2", | ||
"clean-css": "^4.2.1", | ||
"core-js": "^2.6.4", | ||
"css-mqpacker": "^7.0.0", | ||
"fs-extra": "^8.1.0", | ||
"fs-jetpack": "^2.2.2", | ||
"install": "^0.13.0", | ||
"node-notifier": "^5.4.0", | ||
"npm": "^6.11.2", | ||
"postcss": "^7.0.14", | ||
"postcss-nested": "^4.1.1", | ||
"postcss-preset-env": "^6.5.0", | ||
"postcss-prettify": "^0.3.4", | ||
"postcss-smart-import": "^0.7.5", | ||
"rucksack-css": "^1.0.2" | ||
} | ||
"postcss-smart-import": "^0.7.6", | ||
"rollup": "^1.19.4", | ||
"rollup-plugin-babel": "^4.3.2", | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
"rollup-plugin-node-resolve": "^4.0.0", | ||
"save-dev": "^2.0.0", | ||
"temporary": "^1.0.1", | ||
"terser": "^4.2.1", | ||
"uninstall": "0.0.0" | ||
}, | ||
"dependencies": {} | ||
} |
278
README.md
@@ -1,8 +0,19 @@ | ||
## GLightbox | ||
# GLightbox | ||
Glightbox is a pure javascript lightbox. It can display images, iframes, inline content and videos with optional autoplay for youtube, vimeo and even self hosted videos with JWPlayer support | ||
Glightbox is a pure javascript lightbox. It can display images, iframes, inline content and videos with optional autoplay for youtube, vimeo and even self hosted videos. | ||
## Demo | ||
You can check the live demo [right here](https://mcstudios.github.io/glightbox/) | ||
## Features | ||
- **Small** - only 9KB Gzipped | ||
- **Responsive** - works with any screen size | ||
- **Gallery Support** - Create multiple galleries | ||
- **Video Support** - Youtube, Vimeo and self hosted videos with autoplay | ||
- **Inline content support** - display any inline content | ||
- **Iframe support** - need to embed an iframe? no problem | ||
- **Keyboard Navigation** - esc, arrows keys, tab and enter is all you need | ||
- **Touch Navigation** - mobile touch events | ||
- **Api** - control the lightbox with the provided methods | ||
## Live Demo | ||
You can check the live demo [right here](https://biati-digital.github.io/glightbox/) | ||
## Usage | ||
@@ -24,9 +35,235 @@ | ||
``` | ||
```html | ||
<link rel="stylesheet" href="dist/css/glightbox.css"> | ||
<script src="dist/js/glightbox.min.js"></script> | ||
OR CDN | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/glightbox/dist/css/glightbox.min.css"> | ||
<script src="https://cdn.jsdelivr.net/gh/mcstudios/glightbox/dist/js/glightbox.min.js"></script> | ||
<script type="text/javascript"> | ||
const lightbox = GLightbox({ ...options }); | ||
</script> | ||
``` | ||
For more information please check the demo site. | ||
## Examples | ||
```html | ||
<!-- Simple image --> | ||
<a href="large.jpg" class="glightbox"> | ||
<img src="small.jpg" alt="image"> | ||
</a> | ||
<!-- Video --> | ||
<a href="https://vimeo.com/115041822" class="glightbox2"> | ||
<img src="small.jpg" alt="image"> | ||
</a> | ||
<!-- Gallery --> | ||
<a href="large.jpg" class="glightbox3" data-gallery="gallery1"> | ||
<img src="small.jpg" alt="image"> | ||
</a> | ||
<a href="video.mp4" class="glightbox3" data-gallery="gallery1"> | ||
<img src="small.jpg" alt="image"> | ||
</a> | ||
<!-- Simple Description --> | ||
<a href="large.jpg" class="glightbox4" data-glightbox="title: My title; description: this is the slide desciption"> | ||
<img src="small.jpg" alt="image"> | ||
</a> | ||
<!-- Advanced Description --> | ||
<a href="large.jpg" class="glightbox5" data-glightbox="title: My title"> | ||
<img src="small.jpg" alt="image"> | ||
<div class="glightbox-desc"> | ||
<p>Here you can set a more advanced description</p> | ||
<p>With any kind of html</p> | ||
</div> | ||
</a> | ||
``` | ||
## Slide Options | ||
You can specify some options to each individual slide, the available options are: | ||
* title | ||
* description | ||
* descPosition | ||
* type | ||
* effect | ||
* width | ||
* height | ||
```html | ||
<!-- One line config --> | ||
<a href="large.jpg" data-glightbox="title: Your title; description: desciption here; descPosition: left; type: image; effect: fade; width: 900px; height: auto;"></a> | ||
<!-- Multiple data attributes / You can use the options as separated data attributes --> | ||
<a href="large.jpg" data-title="My title" data-description="desciption here" data-descPosition="right" data-type="image" data-effect="fade" data-width="900px" data-height="auto"></a> | ||
``` | ||
## Lightbox Options | ||
Example use of the options. | ||
```javascript | ||
const lightbox = GLightbox({ | ||
touchNavigation: true, | ||
loopAtEnd: true, | ||
autoplayVideos: true, | ||
onOpen: () => { | ||
console.log('Lightbox opened') | ||
}, | ||
beforeSlideLoad: (slide, data) => { | ||
// Need to execute a script in the slide? | ||
// You can do that here... | ||
} | ||
}); | ||
// Instead of using a selector, define the gallery elements | ||
const myGallery = GLightbox({ | ||
elements: [ | ||
{ | ||
'href': 'https://picsum.photos/1200/800', | ||
'type': 'image', | ||
'title': 'My Title', | ||
'description': 'Example', | ||
}, | ||
{ | ||
'href': 'https://picsum.photos/1200/800', | ||
'type': 'image' | ||
}, | ||
{ | ||
'href': 'https://www.youtube.com/watch?v=Ga6RYejo6Hk', | ||
'type': 'video', | ||
'source': 'youtube', //vimeo, youtube or local | ||
'width': 900, | ||
} | ||
], | ||
autoplayVideos: true, | ||
}); | ||
myGallery.open(); | ||
// If later you need to modify the elemnts you can use setElements | ||
myGallery.setElements([...]); | ||
``` | ||
Option | Type | Default | Description | ||
------ | ---- | ------- | ----------- | ||
selector | string | `glightbox` | Class name of the elements. | ||
elements | array | `null` | Instead of passing a selector you can pass all the items that you want in the gallery. | ||
skin | string | `clean` | Name of the skin, it will add a class to the lightbox so you can style it with css. | ||
openEffect | string | `zoomIn` | Name of the effect on lightbox open. (zoom, fade, none) | ||
closeEffect | string | `zoomOut` | Name of the effect on lightbox close. (zoom, fade, none) | ||
slideEffect | string | `slide` | Name of the effect on slide change. (slide, fade, zoom, none) | ||
moreText | string | `See more` | More text for descriptions on mobile devices. | ||
moreLength | number | `60` | Number of characters to display on the description before adding the moreText link (only for mobiles), if 0 it will display the entire description. | ||
closeButton | boolean | `true` | Show or hide the close button. | ||
touchNavigation | boolean | `true` | Enable or disable the touch navigation (swipe). | ||
keyboardNavigation | boolean | `true` | Enable or disable the keyboard navigation. | ||
closeOnOutsideClick | boolean | `true` | Close the lightbox when clicking outside the active slide. | ||
startAt | number | `0` | Start lightbox at defined index. | ||
width | number | `900` | Default with for inline elements and iframes, you can define a specific size on each slide. | ||
height | number | `506` | Default height for inline elements and iframes, you can define a specific size on each slide. **For inline elements you can set the height to auto**. | ||
videosWidth | number | `960` | Default width for videos. Videos are responsive so height is not required. | ||
descPosition | string | `bottom` | Global position for slides description, you can define a specific position on each slide (bottom, top, left, right). | ||
loopAtEnd | boolean | `false` | Loop slide at end. | ||
autoplayVideos | boolean | `true` | Autoplay videos on open. | ||
plyr | object | `{}` | [View video player options.](#player) | ||
## Events | ||
Option | Description | ||
------ | ----------- | ||
onOpen | Provide a function when the lightbox is opened for the first time. | ||
onClose | Provide a function when the lightbox is closed. | ||
beforeSlideChange | Trigger a function before the slide is changed `beforeSlideChange: function(prevSlide, slide) {}` | ||
afterSlideChange | Trigger a function after the slide is changed `afterSlideChange: function(prevSlide, activeSlide) {}` | ||
beforeSlideLoad | Trigger a function before a slide is loaded for the first time, the function will only be called once. `beforeSlideLoad: function(slide, data) {}` | ||
afterSlideLoad | Trigger a function after a slide is loaded for the first time, the function will only be called once. `afterSlideLoad: function(slide, data) {}` | ||
## Video player | ||
Starting from version 2.0.3 glightbox droped support of JWPlayer because that player implemented new restrictions for the free edition, it was replaced with an awesome new player "[Plyr](https://plyr.io/)" that also includes support for youtube and vimeo. So instead of mainating 3 different apis now we only can focus on one. You can pass any Plyr option to the player, view all available options here [Plyr options](https://github.com/sampotts/plyr). | ||
Please note that GLightbox will only inject the video player library if required and only when the lightbox is opened. | ||
```javascript | ||
const lightbox = GLightbox({ | ||
plyr: { | ||
css: 'https://cdn.plyr.io/3.5.6/plyr.css', // Default not required to include | ||
js: 'https://cdn.plyr.io/3.5.6/plyr.js', // Default not required to include | ||
config: { | ||
muted: false, | ||
hideControls: true, | ||
youtube: { | ||
noCookie: true, | ||
rel: 0, | ||
showinfo: 0, | ||
iv_load_policy: 3 | ||
}, | ||
vimeo: { | ||
byline: false, | ||
portrait: false, | ||
title: false, | ||
speed: true, | ||
transparent: false | ||
} | ||
} | ||
} | ||
}); | ||
``` | ||
## Api | ||
There are methods, setters and getters on a GLightbox object. The easiest way to access the GLightbox object is to set the return value from your call to a variable. For example: | ||
```javascript | ||
const lightbox = GLightbox({...options}); | ||
``` | ||
## Methods | ||
Example method use: | ||
```javascript | ||
lightbox.nextSlide(); // Go to next slide | ||
lightbox.close(); // Close de lightbox | ||
``` | ||
Option | Parameters | Description | ||
------ | ------- | ----------- | ||
open | `node` | Open the lightbox, you can optionally pass a node. | ||
close | `-` | Close the lightbox. | ||
reload | `-` | Reload the lightbox, after inserting content with ajax. | ||
destroy | `-` | Destroy and remove all attached events. | ||
prevSlide | `-` | Go to the previous slide. | ||
nextSlide | `-` | Go to the next slide. | ||
goToSlide | `number` | Index of the slide. | ||
getActiveSlide | `-` | Get active slide. It will return the active node. | ||
getActiveSlideIndex | `-` | Get active slide. It will return the active slide index. | ||
playSlideVideo | `number` | Play video in the specified slide. | ||
stopSlideVideo | `number` | Stop video in the specified slide. | ||
setElements | `{}` | Update the lightbox gallery elements. | ||
```javascript | ||
// Example set custom gallery items | ||
lightbox.setElements([ | ||
{ | ||
'href': 'https://picsum.photos/1200/800', | ||
'type': 'image' | ||
}, | ||
{ | ||
'href': 'https://www.youtube.com/watch?v=Ga6RYejo6Hk', | ||
'type': 'video', | ||
'source': 'youtube', //vimeo, youtube or local | ||
'width': 900, | ||
} | ||
]); | ||
// Open the lightbox | ||
lightbox.open(); | ||
``` | ||
## Browser Support | ||
@@ -45,2 +282,12 @@ | ||
## Development | ||
Just run the following commands and that's it. make sure to modify the files inside the src folder, they will be automatically processed and copied to the dist folder. | ||
```bash | ||
$ npm install | ||
$ npm run watch | ||
``` | ||
## Contributing | ||
@@ -52,2 +299,18 @@ | ||
## Changelog | ||
### 2.0.2 | ||
- Fixed StartAt not taking specified index | ||
- Removed JWPlayer because that player implemented some restrictions unless you pay for a license | ||
- Improved mobile touch events, swipe, move, zoom, etc. | ||
- Changed: Youtube now by default uses youtube-nocookie.com, you can enable cookies in the config with youtube.nocookie to false | ||
- New: [Plyr player](https://plyr.io/), we have changed to this player so that wey only one api is managed instead of 3 | ||
- New: Added tabindex accesibility to loop the controls with the tab key | ||
- New: Inside inline content you can close the lightbox by adding the class **gtrigger-close** to any element | ||
- Removed option videosHeight. The height is automatic depending the video width and ratio. | ||
- Removed Gulp and replaced for pure nodejs scripts | ||
- Improved documentation | ||
### 2.0.1 | ||
- Fixed Mobile navigation | ||
- Fixed slide width for external sources | ||
### 2.0.0 | ||
@@ -100,7 +363,4 @@ - Fixed youtube, vimeo autoplay when changing slides | ||
## Todo | ||
- [ ] Improve github description with more documentation and examples | ||
## License | ||
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details |
/** | ||
* GLightbox v2.0.0 | ||
* GLightbox v2.0.2 | ||
* Awesome pure javascript lightbox | ||
* made by mcstudios.com.mx | ||
* made by https://www.biati.digital | ||
*/ | ||
import TouchEvents from './touch-events'; | ||
const isMobile = navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i); | ||
@@ -14,3 +16,2 @@ const isTouch = isMobile !== null || document.createTouch !== undefined || ('ontouchstart' in window) || ('onmsgesturechange' in window) || navigator.msMaxTouchPoints; | ||
let YTTemp = []; | ||
let videoPlayers = { } | ||
@@ -21,5 +22,6 @@ | ||
selector: 'glightbox', | ||
elements: null, | ||
skin: 'clean', | ||
closeButton: true, | ||
startAt: 0, | ||
startAt: null, | ||
autoplayVideos: true, | ||
@@ -30,3 +32,2 @@ descPosition: 'bottom', | ||
videosWidth: 960, | ||
videosHeight: 540, | ||
beforeSlideChange: null, | ||
@@ -42,27 +43,20 @@ afterSlideChange: null, | ||
closeOnOutsideClick: true, | ||
jwplayer: { | ||
api: null, | ||
licenseKey: null, | ||
params: { | ||
width: '100%', | ||
aspectratio: '16:9', | ||
stretching: 'uniform', | ||
plyr: { | ||
css: 'https://cdn.plyr.io/3.5.6/plyr.css', | ||
js: 'https://cdn.plyr.io/3.5.6/plyr.js', | ||
config: { | ||
youtube: { | ||
noCookie: true, | ||
rel: 0, | ||
showinfo: 0, | ||
iv_load_policy: 3 | ||
}, | ||
vimeo: { | ||
byline: false, | ||
portrait: false, | ||
title: false, | ||
transparent: false | ||
} | ||
} | ||
}, | ||
vimeo: { | ||
api: 'https://player.vimeo.com/api/player.js', | ||
params: { | ||
api: 1, | ||
title: 0, | ||
byline: 0, | ||
portrait: 0 | ||
} | ||
}, | ||
youtube: { | ||
api: 'https://www.youtube.com/iframe_api', | ||
params: { | ||
enablejsapi: 1, | ||
showinfo: 0 | ||
} | ||
}, | ||
openEffect: 'zoomIn', // fade, zoom, none | ||
@@ -112,5 +106,5 @@ closeEffect: 'zoomOut', // fade, zoom, none | ||
<div id="glightbox-slider" class="gslider"></div>\ | ||
<a class="gnext"></a>\ | ||
<a class="gprev"></a>\ | ||
<a class="gclose"></a>\ | ||
<button class="gnext gbtn" tabindex="0"></button>\ | ||
<button class="gprev gbtn" tabindex="1"></button>\ | ||
<button class="gclose gbtn" tabindex="2"></button>\ | ||
</div>\ | ||
@@ -204,3 +198,3 @@ </div>'; | ||
* | ||
* @param {mixed} node lisy, array, object | ||
* @param {mixed} node list, array, object | ||
* @param {function} callback | ||
@@ -315,10 +309,3 @@ */ | ||
function addClass(node, name) { | ||
if (hasClass(node, name)) { | ||
return; | ||
} | ||
if (node.classList) { | ||
node.classList.add(name) | ||
} else { | ||
node.className += " " + name | ||
} | ||
each(name.split(' '), cl => node.classList.add(cl)) | ||
} | ||
@@ -333,12 +320,3 @@ | ||
function removeClass(node, name) { | ||
let c = name.split(' ') | ||
if (c.length > 1) { | ||
each(c, (cl) => { removeClass(node, cl) }) | ||
return; | ||
} | ||
if (node.classList) { | ||
node.classList.remove(name) | ||
} else { | ||
node.className = node.className.replace(name, "") | ||
} | ||
each(name.split(' '), cl => node.classList.remove(cl) ) | ||
} | ||
@@ -353,3 +331,3 @@ | ||
function hasClass(node, name) { | ||
return (node.classList ? node.classList.contains(name) : new RegExp("(^| )" + name + "( |$)", "gi").test(node.className)); | ||
return node.classList.contains(name); | ||
} | ||
@@ -496,2 +474,4 @@ | ||
effect: '', | ||
width: '', | ||
height: '', | ||
node: element | ||
@@ -565,3 +545,3 @@ }; | ||
const defaultWith = (data.type == 'video' ? settings.videosWidth : settings.width); | ||
const defaultHeight = (data.type == 'video' ? settings.videosHeight : settings.height); | ||
const defaultHeight = settings.height; | ||
@@ -607,3 +587,3 @@ data.width = (utils.has(data, 'width') ? data.width : defaultWith); | ||
if (slideDesc) { | ||
slideDesc.parentNode.removeChild(slideDesc); | ||
slideDesc.parentNode.parentNode.removeChild(slideDesc.parentNode); | ||
} | ||
@@ -684,7 +664,11 @@ } else{ | ||
const videoID = 'gvideo' + data.index; | ||
// const slideMedia = slide.querySelector('.gslide-media'); | ||
const slideMedia = slide.querySelector('.gvideo-wrapper'); | ||
injectVideoApi(this.settings.plyr.css); | ||
let url = data.href; | ||
let protocol = location.protocol.replace(':', ''); | ||
let videoSource = ''; | ||
let embedID = ''; | ||
let customPlaceholder = false; | ||
@@ -695,152 +679,67 @@ if (protocol == 'file') { | ||
// Set vimeo videos | ||
if (url.match(/vimeo\.com\/([0-9]*)/)) { | ||
const vimeoID = /vimeo.*\/(\d+)/i.exec( url ); | ||
const params = parseUrlParams(this.settings.vimeo.params); | ||
const videoUrl = `${protocol}://player.vimeo.com/video/${vimeoID[1]}?${params}` | ||
slideMedia.parentNode.style.maxWidth = `${data.width}px`; | ||
injectVideoApi(this.settings.vimeo.api); | ||
injectVideoApi(this.settings.plyr.js, 'Plyr', () => { | ||
const finalCallback = function () { | ||
waitUntil(() => { | ||
return typeof Vimeo !== 'undefined'; | ||
}, () => { | ||
const player = new Vimeo.Player(iframe) | ||
videoPlayers[videoID] = player; | ||
if (utils.isFunction(callback)) { | ||
callback() | ||
} | ||
}); | ||
// Set vimeo videos | ||
if (url.match(/vimeo\.com\/([0-9]*)/)) { | ||
const vimeoID = /vimeo.*\/(\d+)/i.exec(url); | ||
videoSource = 'vimeo'; | ||
embedID = vimeoID[1]; | ||
} | ||
slideMedia.parentNode.style.maxWidth = `${data.width}px`; | ||
slideMedia.style.width = `${data.width}px`; | ||
slideMedia.style.maxHeight = `${data.height}px`; | ||
const iframe = createIframe({ | ||
url: videoUrl, | ||
callback: finalCallback, | ||
allow: 'autoplay; fullscreen', | ||
appendTo: slideMedia | ||
}); | ||
iframe.id = videoID; | ||
iframe.className = 'vimeo-video gvideo'; | ||
if (this.settings.autoplayVideos && !isMobile) { | ||
iframe.className += ' wait-autoplay'; | ||
// Set youtube videos | ||
if (url.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/) || url.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)) { | ||
const youtubeID = getYoutubeID(url) | ||
videoSource = 'youtube'; | ||
embedID = youtubeID; | ||
} | ||
} | ||
// Set youtube videos | ||
if (url.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/) || url.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)) { | ||
const youtubeParams = extend(this.settings.youtube.params, { | ||
playerapiid: videoID | ||
}) | ||
const yparams = parseUrlParams(youtubeParams) | ||
const youtubeID = getYoutubeID(url) | ||
const videoUrl = `${protocol}://www.youtube.com/embed/${youtubeID}?${yparams}` | ||
// Set local videos | ||
if (url.match(/\.(mp4|ogg|webm)$/) !== null) { | ||
videoSource = 'local' | ||
let html = '<video id="' + videoID + '" '; | ||
html += `style="background:#000; max-width: ${data.width}px;" `; | ||
html += 'preload="metadata" '; | ||
html += 'x-webkit-airplay="allow" '; | ||
html += 'webkit-playsinline="" '; | ||
html += 'controls '; | ||
html += 'class="gvideo-local">'; | ||
injectVideoApi(this.settings.youtube.api); | ||
let format = url.toLowerCase().split('.').pop() | ||
let sources = {'mp4': '', 'ogg': '', 'webm': ''} | ||
sources[format] = url; | ||
const finalCallback = () => { | ||
if (!utils.isNil(YT) && YT.loaded) { | ||
const player = new YT.Player(iframe); | ||
videoPlayers[videoID] = player; | ||
} else { | ||
YTTemp.push(iframe) | ||
} | ||
if (utils.isFunction(callback)) { | ||
callback() | ||
} | ||
} | ||
slideMedia.parentNode.style.maxWidth = `${data.width}px`; | ||
slideMedia.style.width = `${data.width}px`; | ||
slideMedia.style.maxHeight = `${data.height}px`; | ||
const iframe = createIframe({ | ||
url: videoUrl, | ||
callback: finalCallback, | ||
allow: 'autoplay; fullscreen', | ||
appendTo: slideMedia | ||
}) | ||
iframe.id = videoID | ||
iframe.className = 'youtube-video gvideo'; | ||
if (this.settings.autoplayVideos && !isMobile) { | ||
iframe.className += ' wait-autoplay'; | ||
} | ||
} | ||
// Set local videos | ||
if (url.match(/\.(mp4|ogg|webm)$/) !== null) { | ||
let html = '<video id="' + videoID + '" '; | ||
html += `style="background:#000; width: ${data.width}px; height: ${data.height}px;" `; | ||
html += 'preload="metadata" '; | ||
html += 'x-webkit-airplay="allow" '; | ||
html += 'webkit-playsinline="" '; | ||
html += 'controls '; | ||
html += 'class="gvideo">'; | ||
let format = url.toLowerCase().split('.').pop() | ||
let sources = {'mp4': '', 'ogg': '', 'webm': ''} | ||
sources[format] = url; | ||
for (let key in sources) { | ||
if (sources.hasOwnProperty(key)) { | ||
let videoFile = sources[key] | ||
if (data.hasOwnProperty(key)) { | ||
videoFile = data[key] | ||
for (let key in sources) { | ||
if (sources.hasOwnProperty(key)) { | ||
let videoFile = sources[key] | ||
if (data.hasOwnProperty(key)) { | ||
videoFile = data[key] | ||
} | ||
if (videoFile !== '') { | ||
html += `<source src="${videoFile}" type="video/${key}">`; | ||
} | ||
} | ||
if (videoFile !== '') { | ||
html += `<source src="${videoFile}" type="video/${key}">`; | ||
} | ||
} | ||
html += '</video>'; | ||
customPlaceholder = createHTML(html); | ||
} | ||
html += '</video>'; | ||
const placeholder = customPlaceholder ? customPlaceholder : createHTML(`<div id="${videoID}" data-plyr-provider="${videoSource}" data-plyr-embed-id="${embedID}"></div>`) | ||
let video = createHTML(html); | ||
slideMedia.appendChild(video) | ||
addClass(slideMedia, `${videoSource}-video gvideo`) | ||
slideMedia.appendChild(placeholder) | ||
slideMedia.setAttribute('data-id', videoID) | ||
let vnode = document.getElementById(videoID) | ||
if (this.settings.jwplayer !== null && this.settings.jwplayer.api !== null) { | ||
let jwplayerConfig = this.settings.jwplayer | ||
let jwplayerApi = this.settings.jwplayer.api | ||
const playerConfig = utils.has(this.settings.plyr, 'config') ? this.settings.plyr.config : {}; | ||
const player = new Plyr('#' + videoID, playerConfig); | ||
if (!jwplayerApi) { | ||
console.warn('Missing jwplayer api file'); | ||
if (utils.isFunction(callback)) callback() | ||
return false | ||
player.on('ready', event => { | ||
const instance = event.detail.plyr; | ||
videoPlayers[videoID] = instance; | ||
if (utils.isFunction(callback)) { | ||
callback() | ||
} | ||
injectVideoApi(jwplayerApi, () => { | ||
const jwconfig = extend(this.settings.jwplayer.params, { | ||
width: `${data.width}px`, | ||
height: `${data.height}px`, | ||
file: url | ||
}) | ||
jwplayer.key = this.settings.jwplayer.licenseKey; | ||
const player = jwplayer(videoID); | ||
player.setup(jwconfig); | ||
videoPlayers[videoID] = player; | ||
player.on('ready', () => { | ||
vnode = slideMedia.querySelector('.jw-video') | ||
addClass(vnode, 'gvideo') | ||
vnode.id = videoID | ||
if (utils.isFunction(callback)) callback() | ||
}) | ||
}) | ||
} else{ | ||
addClass(vnode, 'html5-video') | ||
videoPlayers[videoID] = vnode | ||
if (utils.isFunction(callback)) callback() | ||
} | ||
} | ||
}); | ||
}) | ||
} | ||
@@ -878,3 +777,3 @@ | ||
iframe.onload = function() { | ||
addClass(iframe, 'iframe-ready'); | ||
addClass(iframe, 'node-ready'); | ||
if (utils.isFunction(callback)) { | ||
@@ -892,5 +791,2 @@ callback() | ||
/** | ||
@@ -917,3 +813,3 @@ * Get youtube ID | ||
* Inject videos api | ||
* used for youtube, vimeo and jwplayer | ||
* used for video player | ||
* | ||
@@ -923,3 +819,3 @@ * @param {string} url | ||
*/ | ||
function injectVideoApi(url, callback) { | ||
function injectVideoApi(url, waitFor, callback) { | ||
if (utils.isNil(url)) { | ||
@@ -929,39 +825,68 @@ console.error('Inject videos api error'); | ||
} | ||
let found = document.querySelectorAll('script[src="' + url + '"]') | ||
if (utils.isNil(found) || found.length == 0) { | ||
let script = document.createElement('script'); | ||
script.type = 'text/javascript'; | ||
script.src = url; | ||
script.onload = () => { | ||
if (utils.isFunction(callback)) callback(); | ||
}; | ||
document.body.appendChild(script); | ||
return false; | ||
if (utils.isFunction(waitFor)) { | ||
callback = waitFor; | ||
waitFor = false; | ||
} | ||
if (utils.isFunction(callback)) callback(); | ||
} | ||
let found; | ||
/** | ||
* Handle youtube Api | ||
* This is a simple fix, when the video | ||
* is ready sometimes the youtube api is still | ||
* loading so we can not autoplay or pause | ||
* we need to listen onYouTubeIframeAPIReady and | ||
* register the videos if required | ||
*/ | ||
function youtubeApiHandle() { | ||
for (let i = 0; i < YTTemp.length; i++) { | ||
const iframe = YTTemp[i]; | ||
const player = new YT.Player(iframe); | ||
videoPlayers[iframe.id] = player | ||
if (url.indexOf('.css') !== -1) { | ||
found = document.querySelectorAll('link[href="' + url + '"]') | ||
if (found && found.length > 0) { | ||
if (utils.isFunction(callback)) callback(); | ||
return; | ||
} | ||
const head = document.getElementsByTagName("head")[0]; | ||
const headStyles = head.querySelectorAll('link[rel="stylesheet"]'); | ||
const link = document.createElement('link'); | ||
link.rel = 'stylesheet'; | ||
link.type = 'text/css'; | ||
link.href = url; | ||
link.media = 'all'; | ||
if (headStyles) { | ||
head.insertBefore(link, headStyles[0]); | ||
} else { | ||
head.appendChild(link); | ||
} | ||
if (utils.isFunction(callback)) callback(); | ||
return; | ||
} | ||
} | ||
if (typeof window.onYouTubeIframeAPIReady !== 'undefined') { | ||
window.onYouTubeIframeAPIReady = function(){ | ||
window.onYouTubeIframeAPIReady() | ||
youtubeApiHandle() | ||
found = document.querySelectorAll('script[src="' + url + '"]') | ||
if (found && found.length > 0) { | ||
if (utils.isFunction(callback)) { | ||
if (utils.isString(waitFor)) { | ||
waitUntil(() => { | ||
return typeof window[waitFor] !== 'undefined'; | ||
}, () => { | ||
callback(); | ||
}) | ||
return false; | ||
} | ||
callback(); | ||
} | ||
return; | ||
} | ||
} else{ | ||
window.onYouTubeIframeAPIReady = youtubeApiHandle | ||
let script = document.createElement('script'); | ||
script.type = 'text/javascript'; | ||
script.src = url; | ||
script.onload = () => { | ||
if (utils.isFunction(callback)) { | ||
if (utils.isString(waitFor)) { | ||
waitUntil(() => { | ||
return typeof window[waitFor] !== 'undefined'; | ||
}, () => { | ||
callback(); | ||
}) | ||
return false; | ||
} | ||
callback(); | ||
} | ||
}; | ||
document.body.appendChild(script); | ||
return; | ||
} | ||
@@ -999,26 +924,3 @@ | ||
/** | ||
* Parse url params | ||
* convert an object in to a | ||
* url query string parameters | ||
* | ||
* @param {object} params | ||
*/ | ||
function parseUrlParams(params) { | ||
let qs = ''; | ||
let i = 0; | ||
each(params, (val, key) => { | ||
if (i > 0) { | ||
qs += '&'; | ||
} | ||
qs += key + '=' + val; | ||
i += 1; | ||
}) | ||
return qs; | ||
} | ||
/** | ||
* Set slide inline content | ||
@@ -1041,10 +943,17 @@ * we'll extend this to make http | ||
} | ||
const cloned = div.cloneNode(true) | ||
cloned.style.height = `${data.height}px` | ||
cloned.style.maxWidth = `${data.width}px` | ||
cloned.style.height = (utils.isNumber(data.height) ? `${data.height}px` : data.height); | ||
cloned.style.maxWidth = (utils.isNumber(data.width) ? `${data.width}px` : data.width); | ||
addClass(cloned, 'ginlined-content') | ||
slideMedia.appendChild(cloned) | ||
this.events['inlineclose' + hash] = addEvent('click', { | ||
onElement: slideMedia.querySelectorAll('.gtrigger-close'), | ||
withCallback: e => { | ||
e.preventDefault(); | ||
this.close(); | ||
} | ||
}); | ||
if (utils.isFunction(callback)) { | ||
@@ -1110,2 +1019,33 @@ callback() | ||
const key = event.keyCode; | ||
if (key == 9) { | ||
event.preventDefault(); | ||
const btns = document.querySelectorAll('.gbtn'); | ||
if (!btns || btns.length <= 0) { | ||
return; | ||
} | ||
const focused = [...btns].filter(item => hasClass(item, 'focused')) | ||
if (!focused.length) { | ||
const first = document.querySelector('.gbtn[tabindex="0"]'); | ||
if (first) { | ||
first.focus(); | ||
addClass(first, 'focused') | ||
} | ||
return; | ||
} | ||
btns.forEach(element => removeClass(element, 'focused')) | ||
let tabindex = focused[0].getAttribute('tabindex'); | ||
tabindex = tabindex ? tabindex : '0'; | ||
let newIndex = parseInt(tabindex) + 1; | ||
if (newIndex > (btns.length - 1)) { | ||
newIndex = '0'; | ||
} | ||
let next = document.querySelector(`.gbtn[tabindex="${newIndex}"]`); | ||
if (next) { | ||
next.focus(); | ||
addClass(next, 'focused') | ||
} | ||
} | ||
if (key == 39) this.nextSlide(); | ||
@@ -1122,55 +1062,39 @@ if (key == 37) this.prevSlide(); | ||
function touchNavigation() { | ||
if (this.events.hasOwnProperty('touchStart')) { | ||
if (this.events.hasOwnProperty('touch')) { | ||
return false; | ||
} | ||
let index, | ||
hDistance, | ||
vDistance, | ||
hDistanceLast, | ||
vDistanceLast, | ||
hDistancePercent, | ||
vSwipe = false, | ||
hSwipe = false, | ||
hSwipMinDistance = 0, | ||
vSwipMinDistance = 0, | ||
doingPinch = false, | ||
pinchBigger = false, | ||
startCoords = { }, | ||
endCoords = { }, | ||
slider = this.slidesContainer, | ||
activeSlide = null, | ||
xDown = 0, | ||
yDown = 0, | ||
activeSlideImage = null, | ||
activeSlideMedia = null, | ||
activeSlideDesc = null; | ||
let winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; | ||
let winHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; | ||
let body = document.body; | ||
let currentSlide = null; | ||
let media = null; | ||
let mediaImage = null; | ||
let doingMove = false; | ||
let initScale = 1; | ||
let maxScale = 4.5; | ||
let currentScale = 1; | ||
let doingZoom = false; | ||
let imageZoomed = false; | ||
let zoomedPosX = null; | ||
let zoomedPosY = null; | ||
let lastZoomedPosX = null; | ||
let lastZoomedPosY = null; | ||
let hDistance; | ||
let vDistance; | ||
let hDistancePercent = 0; | ||
let vDistancePercent = 0; | ||
let vSwipe = false; | ||
let hSwipe = false; | ||
let startCoords = {}; | ||
let endCoords = {}; | ||
let xDown = 0; | ||
let yDown = 0; | ||
let isInlined; | ||
this.events['doctouchmove'] = addEvent('touchmove', { | ||
onElement: document, | ||
withCallback: (e, target) => { | ||
if (hasClass(body, 'gdesc-open')) { | ||
e.preventDefault() | ||
return false | ||
} | ||
}, useCapture: { passive: false } | ||
}) | ||
const instance = this; | ||
const sliderWrapper = document.getElementById('glightbox-slider'); | ||
const overlay = document.querySelector('.goverlay') | ||
this.events['touchStart'] = addEvent('touchstart', { | ||
onElement: body, | ||
withCallback: (e, target) => { | ||
if (hasClass(body, 'gdesc-open')) { | ||
return; | ||
} | ||
addClass(body, 'touching'); | ||
activeSlide = this.getActiveSlide() | ||
activeSlideImage = activeSlide.querySelector('.gslide-image') | ||
activeSlideMedia = activeSlide.querySelector('.gslide-media') | ||
activeSlideDesc = activeSlide.querySelector('.gslide-description') | ||
index = this.index; | ||
const touchInstance = new TouchEvents(sliderWrapper, { | ||
touchStart: (e) => { | ||
endCoords = e.targetTouches[0]; | ||
@@ -1181,50 +1105,28 @@ startCoords.pageX = e.targetTouches[0].pageX; | ||
yDown = e.targetTouches[0].clientY; | ||
} | ||
}) | ||
this.events['gestureStart'] = addEvent('gesturestart', { | ||
onElement: body, | ||
withCallback: (e, target) => { | ||
if (activeSlideImage) { | ||
e.preventDefault() | ||
doingPinch = true | ||
currentSlide = instance.activeSlide; | ||
media = currentSlide.querySelector('.gslide-media'); | ||
isInlined = currentSlide.querySelector('.gslide-inline'); | ||
mediaImage = null; | ||
if (hasClass(media, 'gslide-image')) { | ||
mediaImage = media.querySelector('img'); | ||
} | ||
} | ||
}) | ||
this.events['gestureChange'] = addEvent('gesturechange', { | ||
onElement: body, | ||
withCallback: (e, target) => { | ||
e.preventDefault() | ||
slideCSSTransform(activeSlideImage, `scale(${e.scale})`) | ||
} | ||
}) | ||
removeClass(overlay, 'greset') | ||
}, | ||
touchMove: (e) => { | ||
endCoords = e.targetTouches[0]; | ||
this.events['gesturEend'] = addEvent('gestureend', { | ||
onElement: body, | ||
withCallback: (e, target) => { | ||
doingPinch = false | ||
if (e.scale < 1) { | ||
pinchBigger = false | ||
slideCSSTransform(activeSlideImage, `scale(1)`) | ||
} else{ | ||
pinchBigger = true | ||
} | ||
} | ||
}) | ||
this.events['touchMove'] = addEvent('touchmove', { | ||
onElement: body, | ||
withCallback: (e, target) => { | ||
if (!hasClass(body, 'touching')) { | ||
if (doingZoom || imageZoomed) { | ||
return; | ||
} | ||
if (hasClass(body, 'gdesc-open') || doingPinch || pinchBigger) { | ||
return; | ||
if (isInlined && isInlined.offsetHeight > winHeight) { // Allow scroll without moving the slide | ||
const moved = startCoords.pageX - endCoords.pageX; | ||
if (Math.abs(moved) <= 13) { | ||
return false; | ||
} | ||
} | ||
e.preventDefault(); | ||
endCoords = e.targetTouches[0]; | ||
let slideHeight = activeSlide.querySelector('.gslide-inner-content').offsetHeight; | ||
let slideWidth = activeSlide.querySelector('.gslide-inner-content').offsetWidth; | ||
doingMove = true; | ||
let xUp = e.targetTouches[0].clientX; | ||
@@ -1235,3 +1137,3 @@ let yUp = e.targetTouches[0].clientY; | ||
if (Math.abs(xDiff) > Math.abs(yDiff)) { /*most significant*/ | ||
if (Math.abs(xDiff) > Math.abs(yDiff)) { | ||
vSwipe = false | ||
@@ -1244,98 +1146,128 @@ hSwipe = true | ||
if (vSwipe) { | ||
vDistanceLast = vDistance; | ||
vDistance = endCoords.pageY - startCoords.pageY; | ||
if (Math.abs(vDistance) >= vSwipMinDistance || vSwipe) { | ||
let opacity = 0.75 - Math.abs(vDistance) / slideHeight; | ||
activeSlideMedia.style.opacity = opacity; | ||
if (activeSlideDesc) { | ||
activeSlideDesc.style.opacity = opacity; | ||
} | ||
slideCSSTransform(activeSlideMedia, `translate3d(0, ${vDistance}px, 0)`) | ||
} | ||
return; | ||
} | ||
hDistanceLast = hDistance; | ||
hDistance = endCoords.pageX - startCoords.pageX; | ||
hDistancePercent = hDistance * 100 / winWidth; | ||
vDistance = endCoords.pageY - startCoords.pageY; | ||
vDistancePercent = vDistance * 100 / winHeight; | ||
let opacity; | ||
if (vSwipe && mediaImage) { | ||
opacity = 1 - Math.abs(vDistance) / winHeight; | ||
overlay.style.opacity = opacity; | ||
} | ||
if (hSwipe) { | ||
if (this.index + 1 == this.elements.length && hDistance < -60) { | ||
resetSlideMove(activeSlide) | ||
return false; | ||
} | ||
if (this.index - 1 < 0 && hDistance > 60) { | ||
resetSlideMove(activeSlide) | ||
return false; | ||
} | ||
opacity = 1 - Math.abs(hDistance) / winWidth; | ||
media.style.opacity = opacity; | ||
} | ||
let opacity = 0.75 - Math.abs(hDistance) / slideWidth; | ||
activeSlideMedia.style.opacity = opacity; | ||
if (activeSlideDesc) { | ||
activeSlideDesc.style.opacity = opacity; | ||
} | ||
slideCSSTransform(activeSlideMedia, `translate3d(${hDistancePercent}%, 0, 0)`) | ||
if (!mediaImage) { | ||
return slideCSSTransform(media, `translate3d(${hDistancePercent}%, 0, 0)`) | ||
} | ||
}, useCapture: { passive: false } | ||
}) | ||
slideCSSTransform(media, `translate3d(${hDistancePercent}%, ${vDistancePercent}%, 0)`) | ||
}, | ||
touchEnd: () => { | ||
doingMove = false; | ||
if (imageZoomed || doingZoom) { | ||
lastZoomedPosX = zoomedPosX; | ||
lastZoomedPosY = zoomedPosY; | ||
return; | ||
} | ||
const v = Math.abs(parseInt(vDistancePercent)); | ||
const h = Math.abs(parseInt(hDistancePercent)); | ||
if (v > 35 && mediaImage) { | ||
this.close(); | ||
return; | ||
} | ||
if (v < 35 && h < 25) { | ||
addClass(overlay, 'greset') | ||
overlay.style.opacity = 1; | ||
return resetSlideMove(media) | ||
} | ||
}, | ||
multipointEnd: () => { | ||
setTimeout(() => { doingZoom = false }, 50); | ||
}, | ||
multipointStart: () => { | ||
doingZoom = true; | ||
initScale = currentScale ? currentScale : 1; | ||
}, | ||
pinch: (evt) => { | ||
if (!mediaImage || doingMove) { | ||
return false; | ||
} | ||
this.events['touchEnd'] = addEvent('touchend', { | ||
onElement: body, | ||
withCallback: (e, target) => { | ||
vDistance = endCoords.pageY - startCoords.pageY; | ||
hDistance = endCoords.pageX - startCoords.pageX; | ||
hDistancePercent = hDistance * 100 / winWidth; | ||
doingZoom = true; | ||
mediaImage.scaleX = mediaImage.scaleY = initScale * evt.zoom; | ||
removeClass(body, 'touching') | ||
let scale = initScale * evt.zoom; | ||
imageZoomed = true; | ||
let slideHeight = activeSlide.querySelector('.gslide-inner-content').offsetHeight; | ||
let slideWidth = activeSlide.querySelector('.gslide-inner-content').offsetWidth; | ||
// Swipe to top/bottom to close | ||
if (vSwipe) { | ||
let onEnd = (slideHeight / 2) | ||
vSwipe = false; | ||
if (Math.abs(vDistance) >= onEnd) { | ||
this.close() | ||
return; | ||
} | ||
resetSlideMove(activeSlide) | ||
return | ||
if (scale <= 1) { | ||
imageZoomed = false; | ||
scale = 1; | ||
lastZoomedPosY = null; | ||
lastZoomedPosX = null; | ||
zoomedPosX = null; | ||
zoomedPosY = null; | ||
mediaImage.setAttribute('style', '') | ||
return; | ||
} | ||
if (scale > maxScale) { // max scale zoom | ||
scale = maxScale; | ||
} | ||
if (hSwipe) { | ||
hSwipe = false; | ||
let where = 'prev' | ||
let asideExist = true | ||
if(hDistance < 0){ | ||
where = 'next' | ||
hDistance = Math.abs(hDistance) | ||
mediaImage.style.transform = `scale3d(${scale}, ${scale}, 1)` | ||
currentScale = scale; | ||
}, | ||
pressMove: (e) => { | ||
if (imageZoomed && !doingZoom) { | ||
var mhDistance = endCoords.pageX - startCoords.pageX; | ||
var mvDistance = endCoords.pageY - startCoords.pageY; | ||
if (lastZoomedPosX) { | ||
mhDistance = mhDistance + lastZoomedPosX; | ||
} | ||
if (where == 'prev' && this.index - 1 < 0) { | ||
asideExist = false | ||
if (lastZoomedPosY) { | ||
mvDistance = mvDistance + lastZoomedPosY; | ||
} | ||
if (where == 'next' && this.index + 1 >= this.elements.length) { | ||
asideExist = false | ||
zoomedPosX = mhDistance; | ||
zoomedPosY = mvDistance; | ||
let style = `translate3d(${mhDistance}px, ${mvDistance}px, 0)`; | ||
if (currentScale) { | ||
style += ` scale3d(${currentScale}, ${currentScale}, 1)` | ||
} | ||
if (asideExist && hDistance >= (slideWidth / 2) - 90) { | ||
if (where == 'next') { | ||
this.nextSlide(); | ||
} | ||
else{ | ||
this.prevSlide(); | ||
} | ||
return; | ||
slideCSSTransform(mediaImage, style) | ||
} | ||
}, | ||
swipe: (evt) => { | ||
if (imageZoomed) { | ||
return; | ||
} | ||
if (doingZoom) { | ||
doingZoom = false; | ||
return; | ||
} | ||
if (evt.direction == 'Left') { | ||
if (this.index == this.elements.length - 1) { | ||
return resetSlideMove(media) | ||
} | ||
resetSlideMove(activeSlide) | ||
this.nextSlide(); | ||
} | ||
if (evt.direction == 'Right') { | ||
if (this.index == 0) { | ||
return resetSlideMove(media) | ||
} | ||
this.prevSlide(); | ||
} | ||
} | ||
}) | ||
}); | ||
this.events['touch'] = touchInstance; | ||
} | ||
function slideCSSTransform(slide, translate = '') { | ||
@@ -1359,3 +1291,3 @@ if (translate == '') { | ||
function resetSlideMove(slide) { | ||
let media = slide.querySelector('.gslide-media') | ||
let media = (hasClass(slide, 'gslide-media') ? slide : slide.querySelector('.gslide-media')) | ||
let desc = slide.querySelector('.gslide-description') | ||
@@ -1379,4 +1311,2 @@ | ||
function slideShortDesc(string, n = 50, wordBoundary = false) { | ||
@@ -1467,3 +1397,4 @@ let useWordBoundary = wordBoundary | ||
let index = this.settings.startAt | ||
if (element) { // if element passed, get the index | ||
if (element && utils.isNil(index)) { // if element passed and startAt is null, get the index | ||
index = this.elements.indexOf(element) | ||
@@ -1475,2 +1406,6 @@ if (index < 0) { | ||
if (utils.isNil(index)) { | ||
index = 0 | ||
} | ||
this.build() | ||
@@ -1519,3 +1454,3 @@ animateElement(this.overlay, (this.settings.openEffect == 'none' ? 'none' : this.settings.cssEfects.fade.in)) | ||
show(this.loader) | ||
this.index = index | ||
this.index = parseInt(index) | ||
@@ -1540,5 +1475,3 @@ let current = this.slidesContainer.querySelector('.current') | ||
show(this.loader); | ||
// console.log("a", this.settings); | ||
let slide_data = getSlideData(this.elements[index], this.settings); | ||
// console.log(slide_data); | ||
slide_data.index = index; | ||
@@ -1756,17 +1689,8 @@ setSlideContent.apply(this, [slide, slide_data, () => { | ||
let videoID = slideVideo.id | ||
if (videoPlayers && videoPlayers.hasOwnProperty(videoID)) { | ||
let player = videoPlayers[videoID] | ||
if (hasClass(slideVideo, 'vimeo-video')) { | ||
player.pause() | ||
const videoID = slideVideo.getAttribute('data-id'); | ||
if (videoPlayers && utils.has(videoPlayers, videoID)) { | ||
const api = videoPlayers[videoID] | ||
if (api && api.play) { | ||
api.pause(); | ||
} | ||
if (hasClass(slideVideo, 'youtube-video')) { | ||
player.pauseVideo() | ||
} | ||
if (hasClass(slideVideo, 'jw-video')) { | ||
player.pause(true) | ||
} | ||
if (hasClass(slideVideo, 'html5-video')) { | ||
player.pause() | ||
} | ||
} | ||
@@ -1786,31 +1710,9 @@ } | ||
let videoID = slideVideo.id; | ||
if (videoPlayers && (utils.has(videoPlayers, videoID) || hasClass(slideVideo, 'wait-autoplay'))) { | ||
waitUntil(() => { | ||
return hasClass(slideVideo, 'iframe-ready') && utils.has(videoPlayers, videoID); | ||
}, () => { | ||
let player = videoPlayers[videoID] | ||
const videoID = slideVideo.getAttribute('data-id'); | ||
if (videoPlayers && utils.has(videoPlayers, videoID)) { | ||
const api = videoPlayers[videoID] | ||
if (hasClass(slideVideo, 'vimeo-video')) { | ||
waitUntil(() => { return player.play; | ||
}, () => { player.play(); }) | ||
} | ||
if (hasClass(slideVideo, 'youtube-video')) { | ||
waitUntil(() => { return player.playVideo; | ||
}, () => { player.playVideo(); }) | ||
} | ||
if (hasClass(slideVideo, 'jw-video')) { | ||
waitUntil(() => { return player.play; | ||
}, () => { player.play(); }) | ||
} | ||
if (hasClass(slideVideo, 'html5-video')) { | ||
player.play(); | ||
} | ||
setTimeout(() => { | ||
removeClass(slideVideo, 'wait-autoplay') | ||
}, 300); | ||
}, 50, 4000); | ||
return false; | ||
if (api && api.play) { | ||
api.play(); | ||
} | ||
} | ||
@@ -1990,2 +1892,3 @@ } | ||
} | ||
this.events = null; | ||
} | ||
@@ -2013,3 +1916,3 @@ | ||
module.exports = (options = { }) => { | ||
/* module.exports = (options = { }) => { | ||
const instance = new GlightboxInit(options); | ||
@@ -2019,2 +1922,9 @@ instance.init() | ||
return instance; | ||
} */ | ||
export default function(options = {}) { | ||
const instance = new GlightboxInit(options); | ||
instance.init() | ||
return instance; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
257534
21
5404
362
29
4
1