vCarousel/public/JS/example.app.js

206 lines
21 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_ts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vCarousel.ts */ "./src/vCarousel.ts");
/// Exemple d'utilisation de vCarousel avec 3 vidéos
try {
// Liste des id des contenants des vidéos à afficher :
var videosContainers_1 = ["vFunanbule", "vForgeron", "vCircuit"];
// Si un id est fourni par l'url, on affiche cette vidéo en premier :
var wantedVideo_1 = "";
if (window.location.hash !== undefined)
wantedVideo_1 = window.location.hash.replace("#", "");
Object(_vCarousel_ts__WEBPACK_IMPORTED_MODULE_0__["vCarousel"])(videosContainers_1, wantedVideo_1);
// 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) {
wantedVideo_1 = link.hash.replace("#", "");
Object(_vCarousel_ts__WEBPACK_IMPORTED_MODULE_0__["vCarousel"])(videosContainers_1, wantedVideo_1);
});
};
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; });
/// La fonction vCarousel reçoit un tableau d'ids des conteneurs HTML des vidéos à afficher successivement.
/// Le tableau n'est pas dédoublonné, pour reste libre d'afficher plusieurs fois la même vidéo durant un tour du carrousel
/// On peut éventuellement fournir l'id de la première vidéo à afficher.
var vCarousel = function (vContainers, firstVideoId) {
if (firstVideoId === void 0) { firstVideoId = ""; }
// On commence par vérifier que les ids de conteneurs fournis sont correctes.
// C'est-à-dire qu'il s'agit bien d'éléments HTML contenant au moins une vidéo.
var realVContainers = [];
for (var _i = 0, vContainers_1 = vContainers; _i < vContainers_1.length; _i++) {
var containerId = vContainers_1[_i];
var checkContainerExist = document.getElementById(containerId);
if (checkContainerExist === null)
console.error("Aucun élément HTML trouvé dans la page pour l'id fourni " + containerId);
else {
var checkVideoExist = document.querySelector("#" + containerId + " video");
if (checkVideoExist === null)
console.error("Aucune balise vidéo trouvée dans l'élément HTML ayant comme id " + containerId);
else
realVContainers.push({ id: containerId, containerElt: checkContainerExist, videoElt: checkVideoExist });
}
}
// Si firstVideoId a été fourni, on vérifie aussi qu'il est valide.
if (firstVideoId !== "" && (realVContainers.findIndex(function (video) { return video.id === firstVideoId; }) === -1)) {
console.error("Vous avez fourni l'id de la vidéo à afficher en premier (" + firstVideoId + "), mais il n'est pas valide.");
firstVideoId = "";
}
// Il doit rester au moins deux vidéos
var nbVContainers = realVContainers.length;
if (nbVContainers < 2)
console.error("Il faut fournir au moins deux conteneurs valides pour faire tourner le carrousel.");
else {
var _loop_1 = function (i) {
var vContainer = realVContainers[i].containerElt;
var video = realVContainers[i].videoElt;
if ((firstVideoId !== "" && realVContainers[i].id !== firstVideoId) || (firstVideoId == "" && i !== 0))
vContainer.style.display = "none";
else
vContainer.style.display = "block"; // nécessaire dans le cas d'un réaffichage
video.addEventListener("ended", function () {
vContainer.style.display = "none";
var nextVContainer, nextHash;
if (i < (nbVContainers - 1)) {
nextVContainer = realVContainers[i + 1].containerElt;
nextHash = realVContainers[i + 1].id;
}
else {
nextVContainer = realVContainers[0].containerElt;
nextHash = realVContainers[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 la première fois pour atteindre l'ancre (à revoir)
window.location.assign("#" + nextHash);
});
};
// Tous les conteneurs sont cachés, sauf celui demandé
// La fin de lecture d'une vidéo provoque l'affichage du suivant
for (var i = 0; i < nbVContainers; i++) {
_loop_1(i);
}
}
};
/***/ })
/******/ });
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAiLCJ3ZWJwYWNrOi8vLy4vc3JjL2V4YW1wbGUudHMiLCJ3ZWJwYWNrOi8vLy4vc3JjL3ZDYXJvdXNlbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO1FBQUE7UUFDQTs7UUFFQTtRQUNBOztRQUVBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBOztRQUVBO1FBQ0E7O1FBRUE7UUFDQTs7UUFFQTtRQUNBO1FBQ0E7OztRQUdBO1FBQ0E7O1FBRUE7UUFDQTs7UUFFQTtRQUNBO1FBQ0E7UUFDQSwwQ0FBMEMsZ0NBQWdDO1FBQzFFO1FBQ0E7O1FBRUE7UUFDQTtRQUNBO1FBQ0Esd0RBQXdELGtCQUFrQjtRQUMxRTtRQUNBLGlEQUFpRCxjQUFjO1FBQy9EOztRQUVBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E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gICAgIGlmICgoZmlyc3RWaWRlb0lkICE9PSBcIlwiICYmIHJlYWxWQ29udGFpbmVyc1tpXS5pZCAhPT0gZmlyc3RWaWRlb0lkKSB8fCAoZmlyc3RWaWRlb0lkID09IFwiXCIgJiYgaSAhPT0gMCkpXG4gICAgICAgICAgICAgICAgdkNvbnRhaW5lci5zdHlsZS5kaXNwbGF5ID0gXCJub25lXCI7XG4gICAgICAgICAgICBlbHNlXG4gICAgICAgICAgICAgICAgdkNvbnRhaW5lci5zdHlsZS5kaXNwbGF5ID0gXCJibG9ja1wiOyAvLyBuw6ljZXNzYWlyZSBkYW5zIGxlIGNhcyBkJ3VuIHLDqWFmZmljaGFnZVxuICAgICAgICAgICAgdmlkZW8uYWRkRXZlbnRMaXN0ZW5lcihcImVuZGVkXCIsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICB2Q29udGFpbmVyLnN0eWxlLmRpc3BsYXkgPSBcIm5vbmVcIjtcbiAgICAgICAgICAgICAgICB2YXIgbmV4dFZDb250YWluZXIsIG5leHRIYXNoO1xuICAgICAgICAgICAgICAgIGlmIChpIDwgKG5iVkNvbnRhaW5lcnMgLSAxKSkge1xuICAgICAgICAgICAgICAgICAgICBuZXh0VkNvbnRhaW5lciA9IHJlYWxWQ29udGFpbmVyc1tpICsgMV0uY29udGFpbmVyRWx0O1xuICAgICAgICAgICAgICAgICAgICBuZXh0SGFzaCA9IHJlYWxWQ29udGFpbmVyc1tpICsgMV0uaWQ7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBuZXh0VkNvbnRhaW5lciA9IHJlYWxWQ29udGFpbmVyc1swXS5jb250YWluZXJFbHQ7XG4gICAgICAgICAgICAgICAgICAgIG5leHRIYXNoID0gcmVhbFZDb250YWluZXJzWzBdLmlkO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBuZXh0VkNvbnRhaW5lci5zdHlsZS5kaXNwbGF5ID0gXCJibG9ja1wiO1xuICAgICAgICAgICAgICAgIC8vIE9uIGFkYXB0ZSBsJ2FuY3JlIGRlIGwndXJsIGRlIG1hbmnDqHJlIMOgIGNlIHF1J2VsbGUgc29pdCBjb2jDqXJlbnRlIGF2ZWMgbGEgdmlkw6lvIGFmZmljaMOpZVxuICAgICAgICAgICAgICAgIC8vIEF0dGVudGlvbiBjYXIgY2VsYSBwZXV0IHByb3ZvcXVlciB1biBkw6lwbGFjZW1lbnQgZGFucyBsYSBwYWdlIGxhIHByZW1pw6hyZSBmb2lzIHBvdXIgYXR0ZWluZHJlIGwnYW5jcmUgKMOgIHJldm9pcilcbiAgICAgICAgICAgICAgICB3aW5kb3cubG9jYXRpb24uYXNzaWduKFwiI1wiICsgbmV4dEhhc2gpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH07XG4gICAgICAgIC8vIFRvdXMgbGVzIGNvbnRlbmV1cnMgc29udCBjYWNow6lzLCBzYXVmIGNlbHVpIGRlbWFuZMOpXG4gICAgICAgIC8vIExhIGZpbiBkZSBsZWN0dXJlIGQndW5lIHZpZMOpbyBwcm92b3F1ZSBsJ2FmZmljaGFnZSBkdSBzdWl2YW50XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgbmJWQ29udGFpbmVyczsgaSsrKSB7XG4gICAgICAgICAgICBfbG9vcF8xKGkpO1xuICAgICAgICB9XG4gICAgfVxufTtcbiJdLCJzb3VyY2VSb290IjoiIn0=