vCarousel/public/JS/example.app.js

248 lines
22 KiB
JavaScript

/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./src/vCarousel.ts":
/*!**************************!*\
!*** ./src/vCarousel.ts ***!
\**************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "vCarousel": () => (/* binding */ vCarousel)
/* harmony export */ });
var errors = __webpack_require__(/*! ./errors.js */ "./src/errors.js");
var vCarousel = (function () {
function vCarousel() {
this._vContainers = [];
this._playFirstVideo = false;
this._playNextVideos = false;
this._noStop = false;
this.nbVContainers = 0;
}
Object.defineProperty(vCarousel.prototype, "vContainers", {
set: function (vContainersIds) {
for (var _i = 0, vContainersIds_1 = vContainersIds; _i < vContainersIds_1.length; _i++) {
var containerId = vContainersIds_1[_i];
var checkContainerExist = document.getElementById(containerId);
if (checkContainerExist === null)
throw new Error(errors.elementNotFound + containerId);
else {
var checkVideoExist = document.querySelector("#" + containerId + " video");
if (checkVideoExist === null)
throw new Error(errors.videoNotFound + containerId);
else
this._vContainers.push({ id: containerId, containerElt: checkContainerExist, videoElt: checkVideoExist });
}
}
this.nbVContainers = this._vContainers.length;
if (this.nbVContainers < 2)
throw new Error(errors.need2Videos);
},
enumerable: false,
configurable: true
});
Object.defineProperty(vCarousel.prototype, "firstVideoId", {
get: function () {
return this._firstVideoId;
},
set: function (firstVideo) {
if ((firstVideo !== "" && this._vContainers.findIndex(function (video) { return video.id === firstVideo; }) !== -1) || (firstVideo === ""))
this._firstVideoId = firstVideo;
},
enumerable: false,
configurable: true
});
Object.defineProperty(vCarousel.prototype, "playFirstVideo", {
set: function (playFirstVideo) {
this._playFirstVideo = playFirstVideo;
},
enumerable: false,
configurable: true
});
Object.defineProperty(vCarousel.prototype, "playNextVideos", {
set: function (playNextVideos) {
this._playNextVideos = playNextVideos;
},
enumerable: false,
configurable: true
});
Object.defineProperty(vCarousel.prototype, "noStop", {
set: function (noStop) {
this._noStop = noStop;
},
enumerable: false,
configurable: true
});
Object.defineProperty(vCarousel.prototype, "currentVideo", {
get: function () {
return this._currentVideo;
},
enumerable: false,
configurable: true
});
vCarousel.prototype.run = function () {
var vCarousel = this;
if (vCarousel.nbVContainers < 2)
throw new Error(errors.needVideosProvided);
var _loop_1 = function (i) {
var vContainer = vCarousel._vContainers[i].containerElt;
var video = vCarousel._vContainers[i].videoElt;
if ((vCarousel._firstVideoId !== undefined && vCarousel._vContainers[i].id !== vCarousel._firstVideoId) || (vCarousel._firstVideoId === undefined && i !== 0) || vCarousel._firstVideoId === "")
vContainer.style.display = "none";
else {
if (vCarousel._currentVideo !== undefined && !vCarousel._currentVideo.paused)
vCarousel._currentVideo.pause();
vContainer.style.display = "block";
vCarousel._currentVideo = video;
if (vCarousel._playFirstVideo === true)
video.play();
}
nbTurn = 0;
video.addEventListener("ended", function () {
if (nbTurn < (vCarousel.nbVContainers - 1) || vCarousel._noStop === true) {
vContainer.style.display = "none";
var nextVContainer = void 0, nextVideo = void 0, nextHash = void 0;
if (i < (vCarousel.nbVContainers - 1)) {
nextVContainer = vCarousel._vContainers[i + 1].containerElt;
nextVideo = vCarousel._vContainers[i + 1].videoElt;
nextHash = vCarousel._vContainers[i + 1].id;
}
else {
nextVContainer = vCarousel._vContainers[0].containerElt;
nextVideo = vCarousel._vContainers[0].videoElt;
nextHash = vCarousel._vContainers[0].id;
}
nextVContainer.style.display = "block";
vCarousel._currentVideo = nextVideo;
window.location.assign("#" + nextHash);
if (vCarousel._playNextVideos === true)
nextVideo.play();
nbTurn++;
}
});
};
var nbTurn;
for (var i = 0; i < vCarousel.nbVContainers; i++) {
_loop_1(i);
}
};
return vCarousel;
}());
/***/ }),
/***/ "./src/errors.js":
/*!***********************!*\
!*** ./src/errors.js ***!
\***********************/
/***/ ((module) => {
module.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."
};
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
(() => {
"use strict";
/*!************************!*\
!*** ./src/example.ts ***!
\************************/
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _vCarousel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vCarousel */ "./src/vCarousel.ts");
try {
var videosContainers = ["vFunanbule", "vForgeron", "vCircuit"];
var testvCarousel_1 = new _vCarousel__WEBPACK_IMPORTED_MODULE_0__.vCarousel();
testvCarousel_1.vContainers = videosContainers;
if (window.location.hash !== undefined && window.location.hash !== "")
testvCarousel_1.firstVideoId = window.location.hash.replace("#", "");
testvCarousel_1.run();
var selectLinks = document.querySelectorAll(".selectVideo");
var _loop_1 = function (i) {
var link = selectLinks[i];
link.addEventListener("click", function (e) {
testvCarousel_1.firstVideoId = link.hash.replace("#", "");
testvCarousel_1.playFirstVideo = true;
testvCarousel_1.run();
});
};
for (var i = 0; i < selectLinks.length; i++) {
_loop_1(i);
}
}
catch (e) {
console.error(e);
}
})();
/******/ })()
;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9KUy9leGFtcGxlLmFwcC5qcyIsIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7OztBQUFBLGFBQWEsbUJBQU8sQ0FBQyxvQ0FBYTtBQUNsQztBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLGdFQUFnRSw4QkFBOEI7QUFDOUY7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EsaURBQWlELCtFQUErRTtBQUNoSTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EsU0FBUztBQUNUO0FBQ0E7QUFDQSxLQUFLO0FBQ0w7QUFDQTtBQUNBO0FBQ0EsU0FBUztBQUNUO0FBQ0EscUZBQXFGLGlDQUFpQztBQUN0SDtBQUNBLFNBQVM7QUFDVDtBQUNBO0FBQ0EsS0FBSztBQUNMO0FBQ0E7QUFD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WQ29udGFpbmVycyA9IDA7XG4gICAgfVxuICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh2Q2Fyb3VzZWwucHJvdG90eXBlLCBcInZDb250YWluZXJzXCIsIHtcbiAgICAgICAgc2V0OiBmdW5jdGlvbiAodkNvbnRhaW5lcnNJZHMpIHtcbiAgICAgICAgICAgIGZvciAodmFyIF9pID0gMCwgdkNvbnRhaW5lcnNJZHNfMSA9IHZDb250YWluZXJzSWRzOyBfaSA8IHZDb250YWluZXJzSWRzXzEubGVuZ3RoOyBfaSsrKSB7XG4gICAgICAgICAgICAgICAgdmFyIGNvbnRhaW5lcklkID0gdkNvbnRhaW5lcnNJZHNfMVtfaV07XG4gICAgICAgICAgICAgICAgdmFyIGNoZWNrQ29udGFpbmVyRXhpc3QgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZChjb250YWluZXJJZCk7XG4gICAgICAgICAgICAgICAgaWYgKGNoZWNrQ29udGFpbmVyRXhpc3QgPT09IG51bGwpXG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihlcnJvcnMuZWxlbWVudE5vdEZvdW5kICsgY29udGFpbmVySWQpO1xuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB2YXIgY2hlY2tWaWRlb0V4aXN0ID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcihcIiNcIiArIGNvbnRhaW5lcklkICsgXCIgdmlkZW9cIik7XG4gICAgICAgICAgICAgICAgICAgIGlmIChjaGVja1ZpZGVvRXhpc3QgPT09IG51bGwpXG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoZXJyb3JzLnZpZGVvTm90Rm91bmQgKyBjb250YWluZXJJZCk7XG4gICAgICAgICAgICAgICAgICAgIGVsc2VcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3ZDb250YWluZXJzLnB1c2goeyBpZDogY29udGFpbmVySWQsIGNvbnRhaW5lckVsdDogY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PSBcImJsb2NrXCI7XG4gICAgICAgICAgICAgICAgdkNhcm91c2VsLl9jdXJyZW50VmlkZW8gPSB2aWRlbztcbiAgICAgICAgICAgICAgICBpZiAodkNhcm91c2VsLl9wbGF5Rmlyc3RWaWRlbyA9PT0gdHJ1ZSlcbiAgICAgICAgICAgICAgICAgICAgdmlkZW8ucGxheSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbmJUdXJuID0gMDtcbiAgICAgICAgICAgIHZpZGVvLmFkZEV2ZW50TGlzdGVuZXIoXCJlbmRlZFwiLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgaWYgKG5iVHVybiA8ICh2Q2Fyb3VzZWwubmJWQ29udGFpbmVycyAtIDEpIHx8IHZDYXJvdXNlbC5fbm9TdG9wID09PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHZDb250YWluZXIuc3R5bGUuZGlzcGxheSA9IFwibm9uZVwiO1xuICAgICAgICAgICAgICAgICAgICB2YXIgbmV4dFZDb250YWluZXIgPSB2b2lkIDAsIG5leHRWaWRlbyA9IHZvaWQgMCwgbmV4dEhhc2ggPSB2b2lkIDA7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpIDwgKHZDYXJvdXNlbC5uYlZDb250YWluZXJzIC0gMSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5leHRWQ29udGFpbmVyID0gdkNhcm91c2VsLl92Q29udGFpbmVyc1tpICsgMV0uY29udGFpbmVyRWx0O1xuICAgICAgICAgICAgICAgICAgICAgICAgbmV4dFZpZGVvID0gdkNhcm91c2VsLl92Q29udGFpbmVyc1tpICsgMV0udmlkZW9FbHQ7XG4gICAgICAgICAgICAgICAgICAgICAgICBuZXh0SGFzaCA9IHZDYXJvdXNlbC5fdkNvbnRhaW5lcnNbaSArIDFdLmlkO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgbmV4dFZDb250YWluZXIgPSB2Q2Fyb3VzZWwuX3ZDb250YWluZXJzWzBdLmNvbnRhaW5lckVsdDtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5leHRWaWRlbyA9IHZDYXJvdXNlbC5fdkNvbnRhaW5lcnNbMF0udmlkZW9FbHQ7XG4gICAgICAgICAgICAgICAgICAgICAgICBuZXh0SGFzaCA9IHZDYXJvdXNlbC5fdkNvbnRhaW5lcnNbMF0uaWQ7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgbmV4dFZDb250YWluZXIuc3R5bGUuZGlzcGxheSA9IFwiYmxvY2tcIjtcbiAgICAgICAgICAgICAgICAgICAgdkNhcm91c2VsLl9jdXJyZW50VmlkZW8gPSBuZXh0VmlkZW87XG4gICAgICAgICAgICAgICAgICAgIHdpbmRvdy5sb2NhdGlvbi5hc3NpZ24oXCIjXCIgKyBuZXh0SGFzaCk7XG4gICAgICAgICAgICAgICAgICAgIGlmICh2Q2Fyb3VzZWwuX3BsYXlOZXh0VmlkZW9zID09PSB0cnVlKVxuICAgICAgICAgICAgICAgICAgICAgICAgbmV4dFZpZGVvLnBsYXkoKTtcbiAgICAgICAgICAgICAgICAgICAgbmJUdXJuKys7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH07XG4gICAgICAgIHZhciBuYlR1cm47XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgdkNhcm91c2VsLm5iVkNvbnRhaW5lcnM7IGkrKykge1xuICAgICAgICAgICAgX2xvb3BfMShpKTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgcmV0dXJuIHZDYXJvdXNlbDtcbn0oKSk7XG5leHBvcnQgeyB2Q2Fyb3VzZWwgfTtcbiIsIm1vZHVsZS5leHBvcnRzID1cbntcbiAgICBlbGVtZW50Tm90Rm91bmQgOiBcIkF1Y3VuIMOpbMOpbWVudCBIVE1MIHRyb3V2w6kgZGFucyBsYS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