vCarousel/public/JS/example.app.js

245 lines
22 KiB
JavaScript
Raw Normal View History

/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
2021-03-31 18:14:03 +02:00
/***/ "./src/vCarousel.ts":
/*!**************************!*\
!*** ./src/vCarousel.ts ***!
\**************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2021-03-31 18:14:03 +02:00
"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 () {
2021-04-29 17:40:20 +02:00
function vCarousel() {
this._vContainers = [];
this._firstVideoId = undefined;
2021-04-29 17:40:20 +02:00
this._playFirstVideo = false;
this._playNextVideos = false;
this._noStop = false;
this.nbVContainers = 0;
this._currentVideo = undefined;
}
2021-04-29 17:40:20 +02:00
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);
2021-04-29 17:40:20 +02:00
else {
var checkVideoExist = document.querySelector("#" + containerId + " video");
if (checkVideoExist === null)
throw new Error(errors.videoNotFound + containerId);
2021-04-29 17:40:20 +02:00
else
this._vContainers.push({ id: containerId, containerElt: checkContainerExist, videoElt: checkVideoExist });
}
}
this.nbVContainers = this._vContainers.length;
if (this.nbVContainers < 2)
throw new Error(errors.need2Videos);
2021-04-29 17:40:20 +02:00
},
enumerable: false,
configurable: true
});
Object.defineProperty(vCarousel.prototype, "firstVideoId", {
get: function () {
return this._firstVideoId;
},
2021-04-29 17:40:20 +02:00
set: function (firstVideo) {
2021-08-04 18:16:02 +02:00
if ((firstVideo !== undefined && firstVideo !== "" && this._vContainers.findIndex(function (video) { return video.id === firstVideo; }) !== -1) || (firstVideo === ""))
2021-04-29 17:40:20 +02:00
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;
2021-04-29 17:40:20 +02:00
},
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
});
2021-04-29 17:40:20 +02:00
vCarousel.prototype.run = function () {
var vCarousel = this;
if (vCarousel.nbVContainers < 2)
throw new Error(errors.needVideosProvided);
2021-03-31 18:14:03 +02:00
var _loop_1 = function (i) {
2021-04-29 17:40:20 +02:00
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;
2021-04-29 17:40:20 +02:00
if (vCarousel._playFirstVideo === true)
video.play();
}
nbTurn = 0;
2021-03-31 18:14:03 +02:00
video.addEventListener("ended", function () {
2021-04-29 17:40:20 +02:00
if (nbTurn < (vCarousel.nbVContainers - 1) || vCarousel._noStop === true) {
vContainer.style.display = "none";
2021-08-04 18:16:02 +02:00
var nextVContainer = void 0, nextVideo = void 0, nextHash = void 0, nextOne = 0;
if (i < (vCarousel.nbVContainers - 1))
nextOne = i + 1;
nextVContainer = vCarousel._vContainers[nextOne].containerElt;
nextVideo = vCarousel._vContainers[nextOne].videoElt;
nextHash = vCarousel._vContainers[nextOne].id;
nextVContainer.style.display = "block";
vCarousel._currentVideo = nextVideo;
window.location.assign("#" + nextHash);
2021-04-29 17:40:20 +02:00
if (vCarousel._playNextVideos === true)
nextVideo.play();
nbTurn++;
}
2021-03-31 18:14:03 +02:00
});
};
var nbTurn;
2021-04-29 17:40:20 +02:00
for (var i = 0; i < vCarousel.nbVContainers; i++) {
2021-03-31 18:14:03 +02:00
_loop_1(i);
}
2021-04-29 17:40:20 +02:00
};
return vCarousel;
}());
2021-03-31 18:14:03 +02:00
/***/ }),
/***/ "./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."
};
2021-03-31 18:14:03 +02:00
/***/ })
/******/ });
/************************************************************************/
/******/ // 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSlMvZXhhbXBsZS5hcHAuanMiLCJtYXBwaW5ncyI6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XJFeGlzdCA9PT0gbnVsbClcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGVycm9ycy5lbGVtZW50Tm90Rm91bmQgKyBjb250YWluZXJJZCk7XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBjaGVja1ZpZGVvRXhpc3QgPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKFwiI1wiICsgY29udGFpbmVySWQgKyBcIiB2aWRlb1wiKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGNoZWNrVmlkZW9FeGlzdCA9PT0gbnVsbClcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihlcnJvcnMudmlkZW9Ob3RGb3VuZCArIGNvbnRhaW5lcklkKTtcbiAgICAgICAgICAgICAgICAgICAgZWxzZVxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdkNvbnRhaW5lcnMucHVzaCh7IGlkOiBjb250YWluZXJJZCwgY29udGFpbmVyRWx0OiBjaGVja0NvbnRhaW5lckV4aXN0LCB2aWRlb0VsdDogY2hlY2tWaWRlb0V4aXN0IH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMubmJWQ29udGFpbmVycyA9IHRoaXMuX3ZDb250YWluZXJzLmxlbmd0aDtcbiAgICAgICAgICAgIGlmICh0aGlzLm5iVkNvbnRhaW5lcnMgPCA