Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 37f7b63

Browse files
author
Nick Litwin
committed
Show IntroJS, wip with detecting if seen before
1 parent 8a6697d commit 37f7b63

File tree

10 files changed

+110
-41
lines changed

10 files changed

+110
-41
lines changed

app/index.jade

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ html
8383

8484
#header(ui-view="header")
8585

86+
.intro-js-container(ng-intro-options="main.introOptions", ng-intro-method="main.startIntro", ng-intro-onexit="main.markIntroCompleted", ng-intro-oncomplete="main.markIntroCompleted")
87+
8688
notifications-bar.notifications(closeIcon="fa fa-times-circle")
8789

8890
toaster-container(toaster-options="{{main.globalToasterConfig}}")

app/layout/header/header.controller.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
angular.module('tc.layout').controller('HeaderController', HeaderController);
55

6-
HeaderController.$inject = ['$state', 'TcAuthService', 'CONSTANTS', '$log', '$rootScope', 'UserService', 'ProfileService', 'IntroService'];
6+
HeaderController.$inject = ['$state', 'TcAuthService', 'CONSTANTS', '$log', '$rootScope', 'UserService', 'ProfileService'];
77

8-
function HeaderController($state, TcAuthService, CONSTANTS, $log, $rootScope, UserService, ProfileService, IntroService) {
8+
function HeaderController($state, TcAuthService, CONSTANTS, $log, $rootScope, UserService, ProfileService) {
99
var vm = this;
1010

1111
vm.constants = CONSTANTS;
@@ -89,7 +89,5 @@
8989
$state.go('home');
9090
});
9191
};
92-
93-
vm.introOptions = IntroService.getIntroData($state.$current.name);
9492
}
9593
})();

app/layout/header/header.jade

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
.header-wrapper(ng-class="{'autocomplete': main.searchTerm.length > 0}")
2-
div(ng-intro-options="vm.introOptions", ng-intro-autostart="true")
3-
42
header.top-header
53
a.logo-link(href="/")
64
// Header content visible on small screens
@@ -53,7 +51,7 @@
5351

5452
a.btn-link.secondary-link(ui-sref="login") LOGIN
5553

56-
a(ng-click="launchIntro();", ng-show="!!vm.introOptions") Intro
54+
//- a(ng-click="launchIntro();", ng-show="!!vm.introOptions") Intro
5755
5856
li.menu-item.link-group(ng-repeat="(menu, items) in vm.menuLinks")
5957
.menu-item-header {{menu}}

app/layout/layout.module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(function() {
22
'use strict';
33

4-
var dependencies = ['angular-intro'];
4+
var dependencies = [];
55

66
angular.module('tc.layout', dependencies);
77

app/services/introduction.service.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
steps:[],
1010
showStepNumbers: true,
1111
exitOnOverlayClick: true,
12-
exitOnEsc:true,
12+
exitOnEsc: true,
1313
nextLabel: 'Next',
1414
prevLabel: 'Back',
1515
skipLabel: 'Skip',
@@ -57,7 +57,7 @@
5757
element: '#stats',
5858
intro: 'This sections contains charts and more in-depth metrics to get a very granular understanding of the activity in this sub-track.',
5959
position: 'top'
60-
},
60+
}
6161
// {
6262
// element: '#navigation',
6363
// intro: 'And finally, go from one active sub-track to another by opening the profile navigation here',

app/topcoder.controller.js

Lines changed: 69 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,78 @@
33

44
angular.module('topcoder').controller('TopcoderController', TopcoderController);
55

6-
TopcoderController.$inject = ['NotificationService', '$rootScope', '$document', 'CONSTANTS'];
6+
TopcoderController.$inject = ['NotificationService', '$rootScope', '$document', 'CONSTANTS', 'IntroService', '$state', '$stateParams', '$timeout', '$log', 'store', 'UserService'];
77

8-
function TopcoderController(NotificationService, $rootScope, $document, CONSTANTS) {
8+
function TopcoderController(NotificationService, $rootScope, $document, CONSTANTS, IntroService, $state, $stateParams, $timeout, $log, store, UserService) {
99
var vm = this;
10-
vm.menuVisible = false;
10+
vm.markIntroCompleted = markIntroCompleted;
11+
var userHandle = UserService.getUserIdentity().handle;
12+
var userId = UserService.getUserIdentity().userId;
1113

12-
// set some $rootScope constants here
13-
$rootScope.DOMAIN = CONSTANTS.domain;
14-
15-
$rootScope.$on('$stateChangeStart', function() {
14+
activate();
15+
16+
function activate() {
17+
$rootScope.DOMAIN = CONSTANTS.domain;
1618
vm.menuVisible = false;
17-
});
18-
$rootScope.$on('$stateChangeSuccess', function(evt, toState, toParams, fromState, fromParams) {
19-
$document[0].body.scrollTop = $document[0].documentElement.scrollTop = 0;
20-
});
21-
22-
// TODO - enable this once we support notificaitons
23-
// $rootScope.$on(CONSTANTS.EVENT_USER_LOGGED_IN, function() {
24-
// NotificationService.getNotifications();
25-
// });
26-
27-
vm.globalToasterConfig = {
28-
'close-button': {
29-
'toast-warning': true,
30-
'toast-error': true,
31-
'toast-success': false
32-
},
33-
'body-output-type': 'trustedHtml',
34-
'position-class': 'toast-top-center'
35-
};
19+
vm.globalToasterConfig = {
20+
'close-button': {
21+
'toast-warning': true,
22+
'toast-error': true,
23+
'toast-success': false
24+
},
25+
'body-output-type': 'trustedHtml',
26+
'position-class': 'toast-top-center'
27+
};
28+
29+
$rootScope.$on('$stateChangeStart', function() {
30+
vm.menuVisible = false;
31+
});
32+
33+
$rootScope.$on('$stateChangeSuccess', function(evt, toState, toParams, fromState, fromParams) {
34+
$document[0].body.scrollTop = $document[0].documentElement.scrollTop = 0;
35+
});
36+
37+
// TODO - enable this once we support notificaitons
38+
// $rootScope.$on(CONSTANTS.EVENT_USER_LOGGED_IN, function() {
39+
// NotificationService.getNotifications();
40+
// });
41+
42+
43+
44+
45+
46+
// TODO: refactor to $watch if possible
47+
$timeout(function() {
48+
if (_.contains($state.current.name, 'profile')) {
49+
if (TcAuthService.isAuthenticated() && $stateParams.userHandle.toLowerCase() === userHandle) {
50+
if (!store.get(userId).profileIntroComplete) {
51+
52+
53+
vm.introOptions = IntroService.getIntroData($state.current.name);
54+
55+
$timeout(function() {
56+
vm.startIntro();
57+
}, 0);
58+
}
59+
}
60+
}
61+
62+
}, 1000);
63+
64+
}
65+
66+
function markIntroCompleted() {
67+
$log.info('Introduction marked as complete.');
68+
69+
console.log(userId + ' has before setting: ', store.get(userId));
70+
if (!store.get(userId)) {
71+
store.set(userId, {
72+
dashboardIntroComplete: true
73+
});
74+
}
75+
store.set(userId, {})
76+
console.log(userId + ' has after setting: ', store.get(userId));
77+
}
78+
3679
}
3780
})();

app/topcoder.module.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727
'angular.filter',
2828
'CONSTANTS',
2929
'dcbImgFallback',
30-
'toaster'
30+
'toaster',
31+
'angular-intro'
3132
];
3233

33-
angular
34-
.module('topcoder', dependencies)
35-
.run(appRun);
34+
angular.module('topcoder', dependencies).run(appRun);
3635

3736
appRun.$inject = ['$rootScope', '$state', 'TcAuthService', '$cookies', 'Helpers', '$log', 'NotificationService', 'CONSTANTS'];
3837

assets/css/topcoder.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ a {
274274
box-shadow: none;
275275
}
276276

277-
& .introjs-disabled {
277+
&.introjs-disabled {
278278
background-color: $gray;
279279
}
280280

assets/images/ico-help-hover.svg

Lines changed: 15 additions & 0 deletions
Loading

assets/images/ico-help-normal.svg

Lines changed: 14 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)