vCarousel/public/JS/example.app.js

1 line
3.2 KiB
JavaScript

(()=>{var e={325:e=>{e.exports={elementNotFound:"Aucun élément HTML trouvé dans la page pour l'id : ",videoNotFound:"Aucune balise vidéo trouvée dans l'élément HTML ayant comme id : ",need2Videos:"Il vous faut fournir au moins deux conteneurs de vidéo valides pour pouvoir lancer le carrousel.",needVideosProvided:"vCarousel ne peut être lancé sans avoir fourni les vidéos concernées."}}},o={};function n(t){var i=o[t];if(void 0!==i)return i.exports;var r=o[t]={exports:{}};return e[t](r,r.exports,n),r.exports}(()=>{"use strict";var e=n(325),o=function(){function o(){this._vContainers=[],this._firstVideoId=void 0,this._playFirstVideo=!1,this._playNextVideos=!1,this._noStop=!1,this.nbVContainers=0,this._currentVideo=void 0}return Object.defineProperty(o.prototype,"vContainers",{set:function(o){for(var n=0,t=o;n<t.length;n++){var i=t[n],r=document.getElementById(i);if(null===r)throw new Error(e.elementNotFound+i);var d=document.querySelector("#"+i+" video");if(null===d)throw new Error(e.videoNotFound+i);this._vContainers.push({id:i,containerElt:r,videoElt:d})}if(this.nbVContainers=this._vContainers.length,this.nbVContainers<2)throw new Error(e.need2Videos)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"firstVideoId",{get:function(){return this._firstVideoId},set:function(e){(void 0!==e&&""!==e&&-1!==this._vContainers.findIndex((function(o){return o.id===e}))||""===e)&&(this._firstVideoId=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"playFirstVideo",{set:function(e){this._playFirstVideo=e},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"playNextVideos",{set:function(e){this._playNextVideos=e},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"noStop",{set:function(e){this._noStop=e},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"currentVideo",{get:function(){return this._currentVideo},enumerable:!1,configurable:!0}),o.prototype.run=function(){var o=this;if(o.nbVContainers<2)throw new Error(e.needVideosProvided);for(var n,t=function(e){var t=o._vContainers[e].containerElt,i=o._vContainers[e].videoElt;void 0!==o._firstVideoId&&o._vContainers[e].id!==o._firstVideoId||void 0===o._firstVideoId&&0!==e||""===o._firstVideoId?t.style.display="none":(void 0===o._currentVideo||o._currentVideo.paused||o._currentVideo.pause(),t.style.display="block",o._currentVideo=i,o._playFirstVideo&&i.play()),n=0,i.addEventListener("ended",(function(){if(n<o.nbVContainers-1||o._noStop){t.style.display="none";var i,r=void 0,d=void 0,s=0;e<o.nbVContainers-1&&(s=e+1),r=o._vContainers[s].containerElt,d=o._vContainers[s].videoElt,i=o._vContainers[s].id,r.style.display="block",o._currentVideo=d,d.currentTime=0,window.location.assign("#"+i),o._playNextVideos&&d.play(),n++}}))},i=0;i<o.nbVContainers;i++)t(i)},o}();try{var t=new o;t.vContainers=["vFunanbule","vForgeron","vCircuit"],void 0!==window.location.hash&&""!==window.location.hash&&(t.firstVideoId=window.location.hash.replace("#","")),t.playNextVideos=!0,t.run();for(var i=document.querySelectorAll(".selectVideo"),r=function(e){var o=i[e];o.addEventListener("click",(function(e){t.firstVideoId=o.hash.replace("#",""),t.playFirstVideo=!0,t.run()}))},d=0;d<i.length;d++)r(d)}catch(e){console.error(e)}})()})();