Browse Source

HUE-6334 [frontend] Close tour on esc

Enrico Berti 8 years ago
parent
commit
9ace227
1 changed files with 12 additions and 0 deletions
  1. 12 0
      desktop/core/src/desktop/templates/hue.mako

+ 12 - 0
desktop/core/src/desktop/templates/hue.mako

@@ -1344,22 +1344,34 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
       text: '${ _ko('This tour will not be shown again, but you can always take it again by clicking on your user name on top right') }<br><br>${ _ko('And now go ') }<b>${ _ko('Query, Explore, Repeat') }</b>!',
     });
 
+    var closeTourOnEsc = function (e) {
+      if (e.keyCode === 27) {
+        tour.cancel();
+      }
+    };
+
     if (ApiHelper.getInstance().getFromTotalStorage('tour', 'show.at.start', true)) {
+      $(document).on('keyup', closeTourOnEsc);
       tour.start();
     }
 
     tour.on('complete', function () {
       ApiHelper.getInstance().setInTotalStorage('tour', 'show.at.start', false);
+      $(document).off('keyup', closeTourOnEsc);
     });
 
     tour.on('cancel', function () {
       ApiHelper.getInstance().setInTotalStorage('tour', 'show.at.start', false);
+      $(document).off('keyup', closeTourOnEsc);
     });
 
     huePubSub.subscribe('show.welcome.tour', function () {
+      $(document).on('keyup', closeTourOnEsc);
       tour.start();
     });
 
+
+
   });
 </script>