2016-10-20 11:39:43 -04:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
2017-02-14 03:34:30 -05:00
|
|
|
App.controller "FeatureOnboardingController", ($scope, settings, event_tracking) ->
|
2017-02-07 10:07:26 -05:00
|
|
|
$scope.onboarding =
|
|
|
|
innerStep: 1
|
2017-02-08 12:19:13 -05:00
|
|
|
nSteps: 4
|
2017-02-14 05:09:37 -05:00
|
|
|
|
|
|
|
$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 = () ->
|
2017-02-14 03:34:30 -05:00
|
|
|
event_tracking.sendMB "shown-track-changes-onboarding"
|
2017-02-14 05:21:45 -05:00
|
|
|
$scope.$applyAsync(() -> $scope.showCollabFeaturesOnboarding = false)
|
2017-02-08 12:19:13 -05:00
|
|
|
|
|
|
|
$scope.gotoPrevStep = () ->
|
|
|
|
if $scope.onboarding.innerStep > 1
|
2017-02-14 05:21:45 -05:00
|
|
|
$scope.$applyAsync(() -> $scope.onboarding.innerStep--)
|
2017-02-08 12:19:13 -05:00
|
|
|
|
|
|
|
$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
|
2016-11-01 12:17:42 -04:00
|
|
|
|
2017-02-14 05:21:45 -05:00
|
|
|
$(document).on "keydown", handleKeydown
|
2016-11-01 12:17:42 -04:00
|
|
|
|
2017-02-14 05:21:45 -05:00
|
|
|
$scope.$on "$destroy", () ->
|
|
|
|
$(document).off "keydown", handleKeydown
|