vCarousel/public/JS/example.app.js

268 lines
28 KiB
JavaScript

/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/example.ts");
/******/ })
/************************************************************************/
/******/ ({
/***/ "./src/example.ts":
/*!************************!*\
!*** ./src/example.ts ***!
\************************/
/*! no exports provided */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _vCarousel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vCarousel */ "./src/vCarousel.ts");
// Exemple d'utilisation simple de vCarousel avec 3 vidéos
try {
// Initialisation vCarousel :
var videosContainers = ["vFunanbule", "vForgeron", "vCircuit"];
var testvCarousel_1 = new _vCarousel__WEBPACK_IMPORTED_MODULE_0__["vCarousel"]();
testvCarousel_1.vContainers = videosContainers;
// Si un id est fourni par l'url, on affiche cette vidéo en premier :
if (window.location.hash !== undefined && window.location.hash !== "")
testvCarousel_1.firstVideoId = window.location.hash.replace("#", "");
// On lance le carrousel :
testvCarousel_1.run();
// Dans le cas où l'utilisateur clique pour sélectionner une vidéo à afficher, on actualise l'affichage :
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; // ici je demande à ce que la lecture de la vidéo choisie soit lancée automatiquement.
testvCarousel_1.run();
});
};
for (var i = 0; i < selectLinks.length; i++) {
_loop_1(i);
}
}
catch (e) {
console.error(e);
}
/***/ }),
/***/ "./src/vCarousel.ts":
/*!**************************!*\
!*** ./src/vCarousel.ts ***!
\**************************/
/*! exports provided: vCarousel */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vCarousel", function() { return vCarousel; });
var vCarousel = /** @class */ (function () {
function vCarousel() {
this._vContainers = [];
this._playFirstVideo = false;
this._playNextVideos = false;
this._noStop = false;
this.nbVContainers = 0;
}
Object.defineProperty(vCarousel.prototype, "vContainers", {
// Les ids reçus doivent correspondre à des éléments HTML contenant une vidéo.
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("Aucun élément HTML trouvé dans la page pour l'id " + containerId + ".");
else {
var checkVideoExist = document.querySelector("#" + containerId + " video");
if (checkVideoExist === null)
throw new Error("Aucune balise vidéo trouvée dans l'élément HTML ayant comme id " + containerId + ".");
else
this._vContainers.push({ id: containerId, containerElt: checkContainerExist, videoElt: checkVideoExist });
}
}
// Il faut au moins 2 vidéos à faire tourner.
this.nbVContainers = this._vContainers.length;
if (this.nbVContainers < 2)
throw new Error("Il faut fournir au moins deux conteneurs de vidéo pour pouvoir faire tourner le carrousel.");
},
enumerable: false,
configurable: true
});
Object.defineProperty(vCarousel.prototype, "firstVideoId", {
// Si this._firstVideoId a été fourni, on vérifie qu'il est présent dans la liste des conteneurs de vidéos.
set: function (firstVideo) {
if (firstVideo !== "" && this._vContainers.findIndex(function (video) { return video.id === firstVideo; }) === -1)
console.error("Vous avez fourni l'id de la vidéo à afficher en premier (" + this._firstVideoId + "), mais il n'est pas valide.");
else
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, "playNextVideo", {
set: function (playNextVideo) {
this._playNextVideos = playNextVideo;
},
enumerable: false,
configurable: true
});
Object.defineProperty(vCarousel.prototype, "noStop", {
set: function (noStop) {
this._noStop = noStop;
},
enumerable: false,
configurable: true
});
vCarousel.prototype.run = function () {
var vCarousel = this; // évite les confusions avec le "this" des événements.
if (vCarousel.nbVContainers < 2) // dans le cas où on lancerait run() sans passer par le setter.
throw new Error("Il faut fournir au moins deux conteneurs valides pour faire tourner le carrousel.");
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 {
// Si une vidéo est déjà visible et en cours de lecture, je la stoppe et remets à 0
// Sinon elle risque de continuer à être lue tout en étant cachée.
if (vCarousel.currentVideo !== undefined && !vCarousel.currentVideo.paused) {
vCarousel.currentVideo.pause();
vCarousel.currentVideo.currentTime = 0;
}
// J'affiche la première vidéo et j'essaye de la lancer, si cela est demandé
vContainer.style.display = "block";
vCarousel.currentVideo = video;
if (vCarousel._playFirstVideo === true)
video.play();
}
nbTurn = 0;
video.addEventListener("ended", function () {
// Sauf si demandé, le carrousel s'arrête lorsque toutes les vidéos ont été affichées une fois.
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";
// On adapte l'ancre de l'url de manière à ce qu'elle soit cohérente avec la vidéo affichée.
// Attention car cela peut provoquer un déplacement dans la page pour atteindre l'ancre.
window.location.assign("#" + nextHash);
if (vCarousel._playNextVideos === true)
nextVideo.play();
vCarousel.currentVideo = nextVideo;
nbTurn++;
}
});
};
var nbTurn;
for (var i = 0; i < vCarousel.nbVContainers; i++) {
_loop_1(i);
}
};
return vCarousel;
}());
/***/ })
/******/ });
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAiLCJ3ZWJwYWNrOi8vLy4vc3JjL2V4YW1wbGUudHMiLCJ3ZWJwYWNrOi8vLy4vc3JjL3ZDYXJvdXNlbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO1FBQUE7UUFDQTs7UUFFQTtRQUNBOztRQUVBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBOztRQUVBO1FBQ0E7O1FBRUE7UUFDQTs7UUFFQTtRQUNBO1FBQ0E7OztRQUdBO1FBQ0E7O1FBRUE7UUFDQTs7UUFFQTtRQUNBO1FBQ0E7UUFDQSwwQ0FBMEMsZ0NBQWdDO1FBQzFFO1FBQ0E7O1FBRUE7UUFDQTtRQUNBO1FBQ0Esd0RBQXdELGtCQUFrQjtRQUMxRTtRQUNBLGlEQUFpRCxjQUFjO1FBQy9EOztRQUVBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQSx5Q0FBeUMsaUNBQWlDO1FBQzFFLGdIQUFnSCxtQkFBbUIsRUFBRTtRQUNySTtRQUNBOztRQUVBO1FBQ0E7UUFDQTtRQUNBLDJCQUEyQiwwQkFBMEIs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h0SGFzaCA9IHZvaWQgMDtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGkgPCAodkNhcm91c2VsLm5iVkNvbnRhaW5lcnMgLSAxKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbmV4dFZDb250YWluZXIgPSB2Q2Fyb3VzZWwuX3ZDb250YWluZXJzW2kgKyAxXS5jb250YWluZXJFbHQ7XG4gICAgICAgICAgICAgICAgICAgICAgICBuZXh0VmlkZW8gPSB2Q2Fyb3VzZWwuX3ZDb250YWluZXJzW2kgKyAxXS52aWRlb0VsdDtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5leHRIYXNoID0gdkNhcm91c2VsLl92Q29udGFpbmVyc1tpICsgMV0uaWQ7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBuZXh0VkNvbnRhaW5lciA9IHZDYXJvdXNlbC5fdkNvbnRhaW5lcnNbMF0uY29udGFpbmVyRWx0O1xuICAgICAgICAgICAgICAgICAgICAgICAgbmV4dFZpZGVvID0gdkNhcm91c2VsLl92Q29udGFpbmVyc1swXS52aWRlb0VsdDtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5leHRIYXNoID0gdkNhcm91c2VsLl92Q29udGFpbmVyc1swXS5pZDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBuZXh0VkNvbnRhaW5lci5zdHlsZS5kaXNwbGF5ID0gXCJibG9ja1wiO1xuICAgICAgICAgICAgICAgICAgICAvLyBPbiBhZGFwdGUgbCdhbmNyZSBkZSBsJ3VybCBkZSBtYW5pw6hyZSDDoCBjZSBxdSdlbGxlIHNvaXQgY29ow6lyZW50ZSBhdmVjIGxhIHZpZMOpbyBhZmZpY2jDqWUuXG4gICAgICAgICAgICAgICAgICAgIC8vIEF0dGVudGlvbiBjYXIgY2VsYSBwZXV0IHByb3ZvcXVlciB1biBkw6lwbGFjZW1lbnQgZGFucyBsYSBwYWdlIHBvdXIgYXR0ZWluZHJlIGwnYW5jcmUuXG4gICAgICAgICAgICAgICAgICAgIHdpbmRvdy5sb2NhdGlvbi5hc3NpZ24oXCIjXCIgKyBuZXh0SGFzaCk7XG4gICAgICAgICAgICAgICAgICAgIGlmICh2Q2Fyb3VzZWwuX3BsYXlOZXh0VmlkZW9zID09PSB0cnVlKVxuICAgICAgICAgICAgICAgICAgICAgICAgbmV4dFZpZGVvLnBsYXkoKTtcbiAgICAgICAgICAgICAgICAgICAgdkNhcm91c2VsLmN1cnJlbnRWaWRlbyA9IG5leHRWaWRlbztcbiAgICAgICAgICAgICAgICAgICAgbmJUdXJuKys7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH07XG4gICAgICAgIHZhciBuYlR1cm47XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgdkNhcm91c2VsLm5iVkNvbnRhaW5lcnM7IGkrKykge1xuICAgICAgICAgICAgX2xvb3BfMShpKTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgcmV0dXJuIHZDYXJvdXNlbDtcbn0oKSk7XG5leHBvcnQgeyB2Q2Fyb3VzZWwgfTtcbiJdLCJzb3VyY2VSb290IjoiIn0=