@@ -9,6 +9,8 @@ if (process.env.NODE_ENV === 'development') {
99 . catch ( ( err ) => console . log ( 'An error occurred trying to install devtools: ' , err ) ) ;
1010}
1111
12+ window . jQuery = require ( 'jquery' ) ;
13+
1214var Environment = require ( '../environment' ) ;
1315Environment . init ( ) ;
1416
@@ -45,6 +47,9 @@ var localLinks = require('local-links');
4547var async = require ( 'async' ) ;
4648var ipc = require ( 'hadron-ipc' ) ;
4749
50+ var TourView = require ( './tour' ) ;
51+ var NetworkOptInView = require ( './network-optin' ) ;
52+
4853var format = require ( 'util' ) . format ;
4954var semver = require ( 'semver' ) ;
5055
@@ -66,7 +71,8 @@ var AutoUpdate = require('../auto-update');
6671
6772var addInspectElementMenu = require ( 'debug-menu' ) . install ;
6873
69- window . jQuery = require ( 'jquery' ) ;
74+ require ( 'bootstrap/js/modal' ) ;
75+ require ( 'bootstrap/js/transition' ) ;
7076
7177ipc . once ( 'app:launched' , function ( ) {
7278 console . log ( 'in app:launched' ) ;
@@ -134,6 +140,7 @@ function getConnection(model, done) {
134140 *
135141 * @see http://learn.humanjavascript.com/react-ampersand/application-pattern
136142 */
143+
137144var Application = View . extend ( {
138145 template : function ( ) {
139146 return [
@@ -142,6 +149,8 @@ var Application = View.extend({
142149 ' <div data-hook="statusbar"></div>' ,
143150 ' <div data-hook="notifications"></div>' ,
144151 ' <div data-hook="layout-container"></div>' ,
152+ ' <div data-hook="tour-container"></div>' ,
153+ ' <div data-hook="optin-container"></div>' ,
145154 '</div>'
146155 ] . join ( '\n' ) ;
147156 } ,
@@ -188,6 +197,10 @@ var Application = View.extend({
188197 'click i.help' : 'onHelpClicked' ,
189198 'click a.help' : 'onHelpClicked'
190199 } ,
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+ } ,
191204 onHelpClicked : function ( evt ) {
192205 evt . preventDefault ( ) ;
193206 evt . stopPropagation ( ) ;
@@ -258,11 +271,37 @@ var Application = View.extend({
258271 } ) ;
259272 this . autoUpdate . render ( ) ;
260273
274+ if ( app . preferences . showFeatureTour ) {
275+ this . showTour ( false ) ;
276+ } else {
277+ this . tourClosed ( ) ;
278+ }
279+
261280 if ( process . env . NODE_ENV !== 'production' ) {
262281 debug ( 'Installing "Inspect Element" context menu' ) ;
263282 addInspectElementMenu ( ) ;
264283 }
265284 } ,
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+ } ,
266305 onPageChange : function ( view ) {
267306 metrics . track ( 'App' , 'viewed' , view . screenName ) ;
268307 this . pageSwitcher . set ( view ) ;
0 commit comments