overleaf/services/web/public/coffee/ide/FeatureOnboardingController.coffee

38 lines
1.3 KiB
CoffeeScript
Raw Normal View History

2016-10-20 11:39:43 -04:00
define [
"base"
], (App) ->
App.controller "FeatureOnboardingController", ($scope, settings, event_tracking) ->
$scope.onboarding =
innerStep: 1
nSteps: 4
$scope.$watch "project.features.trackChangesVisible", (visible) ->
return if !visible?
$scope.showCollabFeaturesOnboarding = window.showTrackChangesOnboarding and visible
2016-10-20 11:39:43 -04:00
2016-10-24 07:20:08 -04:00
$scope.dismiss = () ->
event_tracking.sendMB "shown-track-changes-onboarding"
2017-02-14 05:21:45 -05:00
$scope.$applyAsync(() -> $scope.showCollabFeaturesOnboarding = false)
2017-02-14 16:31:49 -05:00
$(document).off "keydown", handleKeydown
$(document).off "click", $scope.dismiss
$scope.gotoPrevStep = () ->
if $scope.onboarding.innerStep > 1
2017-02-14 05:21:45 -05:00
$scope.$applyAsync(() -> $scope.onboarding.innerStep--)
$scope.gotoNextStep = () ->
if $scope.onboarding.innerStep < 4
2017-02-14 05:21:45 -05:00
$scope.$applyAsync(() -> $scope.onboarding.innerStep++)
2016-10-24 07:20:08 -04:00
2017-02-14 05:21:45 -05:00
handleKeydown = (e) ->
switch e.keyCode
when 37 then $scope.gotoPrevStep() # left directional key
when 39, 13 then $scope.gotoNextStep() # right directional key, enter
when 27 then $scope.dismiss() # escape
2017-02-14 05:21:45 -05:00
$(document).on "keydown", handleKeydown
$(document).on "click", $scope.dismiss
2017-02-14 05:21:45 -05:00
$scope.$on "$destroy", () ->
$(document).off "keydown", handleKeydown
$(document).off "click", $scope.dismiss