-
Notifications
You must be signed in to change notification settings - Fork 12
/
onboardingCtrl.js
114 lines (91 loc) · 4.06 KB
/
onboardingCtrl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
angular.module('starter')
.controller('OnboardingCtrl', function($scope, $state, $ionicSlideBoxDelegate, $ionicLoading,
$rootScope, $stateParams, quantimodoService) {
$scope.$on('$ionicView.beforeEnter', function(e) {
console.debug("OnboardingCtrl beforeEnter");
$rootScope.hideNavigationMenu = true;
if(!$rootScope.user){
quantimodoService.setLocalStorageItem('afterLoginGoToState', 'app.onboarding');
$state.go('app.login');
return;
}
$scope.hideLoader();
quantimodoService.setupOnboardingPages();
if($rootScope.onboardingPages && $rootScope.user){
$rootScope.onboardingPages = $rootScope.onboardingPages.filter(function( obj ) {
return obj.id !== 'loginOnboardingPage';
});
}
$ionicLoading.hide();
});
$scope.$on('$ionicView.enter', function(e) { console.debug("Entering state " + $state.current.name);
});
$scope.$on('$ionicView.afterEnter', function(){
console.debug("OnboardingCtrl afterEnter");
quantimodoService.getConnectorsDeferred(); // Make sure they're ready in advance
});
$scope.$on('$ionicView.beforeLeave', function(){
console.debug("OnboardingCtrl beforeLeave");
//Can't do this here because it makes menu show while searching for reminders
//$rootScope.hideNavigationMenu = false; console.debug('$rootScope.hideNavigationMenu = false');
});
$scope.$on('$ionicView.leave', function(){
});
$scope.$on('$ionicView.afterLeave', function(){
});
var removeImportPage = function () {
quantimodoService.setLocalStorageItem('afterLoginGoTo', window.location.href);
var onboardingPages = $rootScope.onboardingPages.filter(function( obj ) {
return obj.id.indexOf('import') === -1;
});
quantimodoService.setLocalStorageItem('onboardingPages', JSON.stringify(onboardingPages));
};
$scope.onboardingGoToImportPage = function () {
$rootScope.hideHomeButton = true;
$rootScope.hideMenuButton = true;
removeImportPage();
$rootScope.onboardingPages[0].nextPageButtonText = "Done connecting data sources";
$state.go('app.import');
};
$scope.skipOnboarding = function () {
$rootScope.hideMenuButton = false;
window.localStorage.onboarded = true;
$state.go(config.appSettings.defaultState);
};
$rootScope.showMoreOnboardingInfo = function () {
$scope.onHelpButtonPress($rootScope.onboardingPages[0].title, $rootScope.onboardingPages[0].moreInfo);
};
$scope.goToReminderSearchCategoryFromOnboarding = function() {
$rootScope.hideHomeButton = true;
$rootScope.hideMenuButton = true;
if(!$rootScope.user){
$rootScope.onboardingPages = null;
quantimodoService.deleteItemFromLocalStorage('onboardingPages');
$state.go('app.onboarding');
return;
}
$scope.goToReminderSearchCategory($rootScope.onboardingPages[0].variableCategoryName);
};
$scope.enableLocationTracking = function () {
$rootScope.trackLocationChange(true, true);
$rootScope.hideOnboardingPage();
};
$scope.doneOnboarding = function () {
$state.go('app.remindersInbox');
$rootScope.hideMenuButton = false;
window.localStorage.onboarded = true;
quantimodoService.deleteItemFromLocalStorage('onboardingPages');
};
$scope.hideOnboardingPage = function () {
$rootScope.onboardingPages = $rootScope.onboardingPages.filter(function( obj ) {
return obj.id !== $rootScope.onboardingPages[0].id;
});
quantimodoService.setLocalStorageItem('onboardingPages', JSON.stringify($rootScope.onboardingPages));
if(!$rootScope.onboardingPages || $rootScope.onboardingPages.length === 0){
$rootScope.hideMenuButton = false;
$state.go(config.appSettings.defaultState);
} else {
$rootScope.hideMenuButton = true;
}
};
});