vCarousel/public/JS/example.app.js

250 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._firstVideoId = undefined;
this._playFirstVideo = false;
this._playNextVideos = false;
this._noStop = false;
this.nbVContainers = 0;
this._currentVideo = undefined;
}
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9KUy9leGFtcGxlLmFwcC5qcyIsIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7OztBQUFBLGFBQWEsbUJBQU8sQ0FBQyxvQ0FBYTtBQUNsQztBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSxnRUFBZ0UsOEJBQThCO0FBQzlGO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLGlEQUFpRCwrRUFBK0U7QUFDaEk7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLFNBQVM7QUFDVDtBQUNBO0FBQ0EsS0FBSztBQUNMO0FBQ0E7QUFDQTtBQUNBLFNBQVM7QUFDVDtBQUNBLHFGQUFxRixpQ0FBaUM7QUFDdEg7QUFDQSxTQUFTO0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cy5fcGxheU5leHRWaWRlb3MgPSBmYWxzZTtcbiAgICAgICAgdGhpcy5fbm9TdG9wID0gZmFsc2U7XG4gICAgICAgIHRoaXMubmJWQ29udGFpbmVycyA9IDA7XG4gICAgICAgIHRoaXMuX2N1cnJlbnRWaWRlbyA9IHVuZGVmaW5lZDtcbiAgICB9XG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHZDYXJvdXNlbC5wcm90b3R5cGUsIFwidkNvbnRhaW5lcnNcIiwge1xuICAgICAgICBzZXQ6IGZ1bmN0aW9uICh2Q29udGFpbmVyc0lkcykge1xuICAgICAgICAgICAgZm9yICh2YXIgX2kgPSAwLCB2Q29udGFpbmVyc0lkc18xID0gdkNvbnRhaW5lcnNJZHM7IF9pIDwgdkNvbnRhaW5lcnNJZHNfMS5sZW5ndGg7IF9pKyspIHtcbiAgICAgICAgICAgICAgICB2YXIgY29udGFpbmVySWQgPSB2Q29udGFpbmVyc0lkc18xW19pXTtcbiAgICAgICAgICAgICAgICB2YXIgY2hlY2tDb250YWluZXJFeGlzdCA9IGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKGNvbnRhaW5lcklkKTtcbiAgICAgICAgICAgICAgICBpZiAoY2hlY2tDb250YWluZXJFeGlzdCA9PT0gbnVsbClcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGVycm9ycy5lbGVtZW50Tm90Rm91bmQgKyBjb250YWluZXJJZCk7XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBjaGVja1ZpZGVvRXhpc3QgPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKFwiI1wiICsgY29udGFpbmVySWQgKyBcIiB2aWRlb1wiKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGNoZWNrVmlkZW9FeGlzdCA9PT0gbnVsbClcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihlcnJvcnMudmlkZW9Ob3RGb3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m91c2VsLl9jdXJyZW50VmlkZW8ucGF1c2VkKVxuICAgICAgICAgICAgICAgICAgICB2Q2Fyb3VzZWwuX2N1cnJlbnRWaWRlby5wYXVzZSgpO1xuICAgICAgICAgICAgICAgIHZDb250YWluZXIuc3R5bGUuZGlzcGxheSA9IFwiYmxvY2tcIjtcbiAgICAgICAgICAgICAgICB2Q2Fyb3VzZWwuX2N1cnJlbnRWaWRlbyA9IHZpZGVvO1xuICAgICAgICAgICAgICAgIGlmICh2Q2Fyb3VzZWwuX3BsYXlGaXJzdFZpZGVvID09PSB0cnVlKVxuICAgICAgICAgICAgICAgICAgICB2aWRlby5wbGF5KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBuYlR1cm4gPSAwO1xuICAgICAgICAgICAgdmlkZW8uYWRkRXZlbnRMaXN0ZW5lcihcImVuZGVkXCIsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBpZiAobmJUdXJuIDwgKHZDYXJvdXNlbC5uYlZDb250YWluZXJzIC0gMSkgfHwgdkNhcm91c2VsLl9ub1N0b3AgPT09IHRydWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdkNvbnRhaW5lci5zdHlsZS5kaXNwbGF5ID0gXCJub25lXCI7XG4gICAgICAgICAgICAgICAgICAgIHZhciBuZXh0VkNvbnRhaW5lciA9IHZvaWQgMCwgbmV4dFZpZGVvID0gdm9pZCAwLCBuZXh0SGFzaCA9IHZvaWQgMDtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGkgPCAodkNhcm91c2VsLm5iVkNvbnRhaW5lcnMgLSAxKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbmV4dFZDb250YWluZXIgPSB2Q2Fyb3VzZWwuX3ZDb250YWluZXJzW2kgKyAxXS5jb250YWluZXJFbHQ7XG4gICAgICAgICAgICAgICAgICAgICAgICBuZXh0VmlkZW8gPSB2Q2Fyb3VzZWwuX3ZDb250YWluZXJzW2kgKyAxXS52aWRlb0VsdDtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5leHRIYXNoID0gdkNhcm91c2VsLl92Q29udGFpbmVyc1tpICsgMV0uaWQ7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBuZXh0VkNvbnRhaW5lciA9IHZDYXJvdXNlbC5fdkNvbnRhaW5lcnNbMF0uY29udGFpbmVyRWx0O1xuICAgICAgICAgICAgICAgICAgICAgICAgbmV4dFZpZGVvID0gdkNhcm91c2VsLl92Q29udGFpbmVyc1swXS52aWRlb0VsdDtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5leHRIYXNoID0gdkNhcm91c2VsLl92Q29udGFpbmVyc1swXS5pZDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBuZXh0VkNvbnRhaW5lci5zdHlsZS5kaXNwbGF5ID0gXCJibG9ja1wiO1xuICAgICAgICAgICAgICAgICAgICB2Q2Fyb3VzZWwuX2N1cnJlbnRWaWRlbyA9IG5leHRWaWRlbztcbiAgICAgICAgICAgICAgICAgICAgd2luZG93LmxvY2F0aW9uLmFzc2lnbihcIiNcIiArIG5leHRIYXNoKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHZDYXJvdXNlbC5fcGxheU5leHRWaWRlb3MgPT09IHRydWUpXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXh0VmlkZW8ucGxheSgpO1xuICAgICAgICAgICAgICAgICAgICBuYlR1cm4rKztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfTtcbiAgICAgICAgdmFyIG5iVHVybjtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCB2Q2Fyb3VzZWwubmJWQ29udGFpbmVyczsgaSsrKSB7XG4gICAgICAgICAgICBfbG9vcF8xKGkpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICByZXR1cm4gdkNhcm91c2VsO1xufSgpK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