--- /dev/null
+function FluidbookStatsEsm(fluidbook) {
+ this.fluidbook = fluidbook;
+ this.init();
+}
+
+FluidbookStatsEsm.prototype = {
+ init: function () {
+ let $this = this;
+
+ // Page change
+ $(this.fluidbook).on('fluidbook.page.change.end', function (e, page) {
+ $this.changePage(page);
+ return true;
+ });
+
+ // Menus (horizontal et mobile)
+ $(document).on('click', '#horizontalNav a, #menuList a', function () {
+ $this.clickNav($(this).attr('id'));
+ return true;
+ });
+
+ // Donner avis
+ $(document).on('click', '#afterSearch a', function () {
+ $this.event('donner_avis');
+ return true;
+ });
+
+ // index page
+ $(document).on('click', '.indexView a', function () {
+ $this.event('index_page');
+ return true;
+ });
+ // logo
+ $(document).on('click', '#logo', function () {
+ $this.event('logo_esm');
+ return true;
+ });
+ // Activer / Désactiver bookmark
+ $(document).on('click', 'a.bookmark', function () {
+ let a = this;
+ setTimeout(function () {
+ if ($(a).attr('data-enabled') !== 'enabled') {
+ $this.event('retrait_marque_page')
+ } else {
+ $this.event('ajout_marque_page')
+ }
+ }, 250);
+ return true;
+ });
+
+ // Mode article
+ $(document).on('click', 'a[href^="#/article"]', function () {
+ $this.event('mode_article');
+ return true;
+ });
+
+ // Recherche mot
+ $(document).on('click', 'a.hint', function () {
+ $this.event('recherche_terme');
+ return true;
+ });
+
+ // Audiodescription
+ $(document).on('click', 'a.audio-description-button', function () {
+ let a = this;
+ setTimeout(function () {
+ if ($(a).hasClass('playing')) {
+ $this.event('activer_ecoute')
+ } else {
+ $this.event('desactiver_ecoute')
+ }
+ }, 250);
+ return true;
+ });
+
+ // Télécharger et imprimer
+ $(document).on('click', 'a#confirmChoice', function () {
+ if ($(this).attr('data-mode') === 'download') {
+ $this.event('telecharger_validation')
+ } else {
+ $this.event('imprimer_validation')
+ }
+ return true;
+ });
+
+ // Partage
+ $(document).on('click', '.shareList a[data-service]', function () {
+ $this.event('partager_validation_' + $(this).attr('data-service'));
+ return true;
+ });
+
+ },
+
+ changePage: function (page) {
+ window.tc_vars.magazine_page = page;
+ window.tc_vars.env_url = window.tc_vars.magazine_name + '/' + window.tc_vars.magazine_region + '/' + window.tc_vars.magazine_page;
+ tC.container.reload({events: {page: [{}, {}]}});
+ },
+
+ clickNav: function (id) {
+ if (id === undefined) {
+ return;
+ }
+ let e = id.split('_', 2);
+ if (e.length !== 2) {
+ return;
+ }
+ id = e[1];
+ let name = this.getClickName(id);
+ if (name !== false) {
+ this.event(name);
+ }
+ },
+
+ getClickName: function (id) {
+ if (id === 'fullscreen') {
+ if (screenfull.isFullscreen) {
+ return 'reduire_ecran';
+ } else {
+ return 'plein_ecran';
+ }
+ }
+
+ let map = {
+ 'index': 'index',
+ 'chapters': 'sommaire',
+ 'searchIcon': 'recherche',
+ 'share': 'partager',
+ 'print': 'imprimer',
+ 'bookmarks': 'liste_marque_page',
+ 'download': 'telecharger',
+ 'sound-off': 'activer_son',
+ 'sound-on': 'desactiver_son',
+ 'help': 'aide',
+ };
+
+ if (map[id] !== undefined && map[id] !== null) {
+ return map[id];
+ }
+ return false;
+ },
+
+ event: function (name, type) {
+ if (type === undefined) {
+ type = 'navigation';
+ }
+
+ console.log('esm event', name);
+ tC.event.click(this, {
+ 'click_name': name, 'click_type': type,
+ });
+ }
+}
\ No newline at end of file