@@ -9,6 +9,8 @@ if (process.env.NODE_ENV === 'development') {
9
9
. catch ( ( err ) => console . log ( 'An error occurred trying to install devtools: ' , err ) ) ;
10
10
}
11
11
12
+ window . jQuery = require ( 'jquery' ) ;
13
+
12
14
var Environment = require ( '../environment' ) ;
13
15
Environment . init ( ) ;
14
16
@@ -45,6 +47,9 @@ var localLinks = require('local-links');
45
47
var async = require ( 'async' ) ;
46
48
var ipc = require ( 'hadron-ipc' ) ;
47
49
50
+ var TourView = require ( './tour' ) ;
51
+ var NetworkOptInView = require ( './network-optin' ) ;
52
+
48
53
var format = require ( 'util' ) . format ;
49
54
var semver = require ( 'semver' ) ;
50
55
@@ -66,7 +71,8 @@ var AutoUpdate = require('../auto-update');
66
71
67
72
var addInspectElementMenu = require ( 'debug-menu' ) . install ;
68
73
69
- window . jQuery = require ( 'jquery' ) ;
74
+ require ( 'bootstrap/js/modal' ) ;
75
+ require ( 'bootstrap/js/transition' ) ;
70
76
71
77
ipc . once ( 'app:launched' , function ( ) {
72
78
console . log ( 'in app:launched' ) ;
@@ -134,6 +140,7 @@ function getConnection(model, done) {
134
140
*
135
141
* @see http://learn.humanjavascript.com/react-ampersand/application-pattern
136
142
*/
143
+
137
144
var Application = View . extend ( {
138
145
template : function ( ) {
139
146
return [
@@ -142,6 +149,8 @@ var Application = View.extend({
142
149
' <div data-hook="statusbar"></div>' ,
143
150
' <div data-hook="notifications"></div>' ,
144
151
' <div data-hook="layout-container"></div>' ,
152
+ ' <div data-hook="tour-container"></div>' ,
153
+ ' <div data-hook="optin-container"></div>' ,
145
154
'</div>'
146
155
] . join ( '\n' ) ;
147
156
} ,
@@ -188,6 +197,10 @@ var Application = View.extend({
188
197
'click i.help' : 'onHelpClicked' ,
189
198
'click a.help' : 'onHelpClicked'
190
199
} ,
200
+ initialize : function ( ) {
201
+ ipc . on ( 'window:show-compass-tour' , this . showTour . bind ( this , true ) ) ;
202
+ ipc . on ( 'window:show-network-optin' , this . showOptIn . bind ( this ) ) ;
203
+ } ,
191
204
onHelpClicked : function ( evt ) {
192
205
evt . preventDefault ( ) ;
193
206
evt . stopPropagation ( ) ;
@@ -258,11 +271,37 @@ var Application = View.extend({
258
271
} ) ;
259
272
this . autoUpdate . render ( ) ;
260
273
274
+ if ( app . preferences . showFeatureTour ) {
275
+ this . showTour ( false ) ;
276
+ } else {
277
+ this . tourClosed ( ) ;
278
+ }
279
+
261
280
if ( process . env . NODE_ENV !== 'production' ) {
262
281
debug ( 'Installing "Inspect Element" context menu' ) ;
263
282
addInspectElementMenu ( ) ;
264
283
}
265
284
} ,
285
+ showTour : function ( force ) {
286
+ var tourView = new TourView ( { force : force } ) ;
287
+ if ( tourView . features . length > 0 ) {
288
+ tourView . on ( 'close' , this . tourClosed . bind ( this ) ) ;
289
+ this . renderSubview ( tourView , this . queryByHook ( 'tour-container' ) ) ;
290
+ } else {
291
+ this . tourClosed ( ) ;
292
+ }
293
+ } ,
294
+ showOptIn : function ( ) {
295
+ var networkOptInView = new NetworkOptInView ( ) ;
296
+ this . renderSubview ( networkOptInView , this . queryByHook ( 'optin-container' ) ) ;
297
+ } ,
298
+ tourClosed : function ( ) {
299
+ app . preferences . unset ( 'showFeatureTour' ) ;
300
+ app . preferences . save ( ) ;
301
+ if ( ! app . preferences . showedNetworkOptIn ) {
302
+ this . showOptIn ( ) ;
303
+ }
304
+ } ,
266
305
onPageChange : function ( view ) {
267
306
metrics . track ( 'App' , 'viewed' , view . screenName ) ;
268
307
this . pageSwitcher . set ( view ) ;
0 commit comments