'use strict'; Application.Services.factory('Help', ['$uibModal', '$state', function ($uibModal, $state) { const TOURS = { 'app.public.home': 'welcome', 'app.public.machines_list': 'machines', 'app.public.spaces_list': 'spaces', 'app.admin.trainings': 'trainings', 'app.admin.calendar': 'calendar', 'app.admin.members': 'members', 'app.admin.invoices': 'invoices', 'app.admin.pricing': 'pricing', 'app.admin.events': 'events', 'app.admin.project_elements': 'project_elements', 'app.admin.statistics': 'statistics', 'app.admin.settings': 'settings', 'app.admin.open_api_clients': 'open_api' }; return function (e) { if (e.key === 'F1') { e.preventDefault(); // retrieve the tour name, based on the current location const tour = TOURS[$state.current.name]; // if no tour, just open the guide if (tour === undefined) { return window.open('https://github.com/sleede/fab-manager/raw/master/doc/fr/guide_utilisation_fab_manager_v4.3.pdf', '_blank'); } $uibModal.open({ animation: true, templateUrl: '<%= asset_path "shared/help_modal.html" %>', controller: ['$scope', '$uibModalInstance', 'uiTourService', function ($scope, $uibModalInstance, uiTourService) { // start the tour and hide the modal $scope.onTour = function () { const tour = uiTourService.getTourByName(tour); if (tour) { tour.start(); } $uibModalInstance.close('tour'); }; // open the user's guide and hide the modal $scope.onGuide = function () { $uibModalInstance.close('guide'); }; }] }); } }; }]);