From 86ae46e4c30ed2f33f9e46c99b3f4777883790e2 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 4 Mar 2020 17:53:43 +0100 Subject: [PATCH] Display user's manual when help is asked, if no tour is available --- CHANGELOG.md | 1 + .../javascripts/controllers/application.js.erb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87f5ab940..669a85966 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog Fab-manager - Updated user's manual for v4.3 (fr) +- Display user's manual when help is asked, if no tour is available - Change style and pluralize the text of the slot division alert in new availability assistant - Fix a bug: in feature tours, next and previous arrows may be broken on some systems - Fix a bug: in the user's menu, two links to the personal wallet diff --git a/app/assets/javascripts/controllers/application.js.erb b/app/assets/javascripts/controllers/application.js.erb index b5d2019b7..b409038b1 100644 --- a/app/assets/javascripts/controllers/application.js.erb +++ b/app/assets/javascripts/controllers/application.js.erb @@ -344,6 +344,24 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco $scope.isAuthenticated = Auth.isAuthenticated; $scope.isAuthorized = AuthService.isAuthorized; $rootScope.login = $scope.login; + + // handle F1 key to trigger help + window.addEventListener('keydown', function(e) { + if (e.key === 'F1') { + if ($rootScope.currentUser.role !== 'admin') return; + + e.preventDefault(); + // we wait a little bit and then, check if a tour has started (by checking for a tour popover). + // if not, we consider that we are on a page that does not provides a tour so we fallback to the default behavior + // -> opening the user's manual + setTimeout(function() { + const tourPopover = document.querySelector('.ui-tour-popup'); + if (!tourPopover || (tourPopover.offsetTop === 0 && tourPopover.offsetTop === 0)) { + window.open('https://github.com/sleede/fab-manager/raw/master/doc/fr/guide_utilisation_fab_manager_v4.3.pdf', '_blank'); + } + }, 300); + } + }); }; /**