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
|
2016-10-20 11:39:43 -04:00
|
|
|
|
2016-10-24 07:20:08 -04:00
|
|
|
$scope.dismiss = () ->
|
2017-02-15 03:47:37 -05:00
|
|
|
event_tracking.sendMB "shown-track-changes-onboarding-2"
|
|
|
|
$scope.$applyAsync(() -> $scope.ui.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
|
2017-02-14 07:09:05 -05:00
|
|
|
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
|
2017-02-14 07:09:05 -05:00
|
|
|
$(document).on "click", $scope.dismiss
|
2016-11-01 12:17:42 -04:00
|
|
|
|
2017-02-14 05:21:45 -05:00
|
|
|
$scope.$on "$destroy", () ->
|
2017-02-14 07:09:05 -05:00
|
|
|
$(document).off "keydown", handleKeydown
|
|
|
|
$(document).off "click", $scope.dismiss
|