@@ -39,10 +39,6 @@ var connectWindow;
3939// since this code was laid down.
4040var windowsOpenCount = 0 ;
4141
42- function isConnectDialog ( url ) {
43- return url === DEFAULT_URL ;
44- }
45-
4642// returns true if the application is a single instance application otherwise
4743// focus the second window (which we'll quit from) and return false
4844// see "app.makeSingleInstance" in https://github.com/atom/electron/blob/master/docs/api/app.md
@@ -90,7 +86,7 @@ module.exports.create = function(opts) {
9086 url : DEFAULT_URL
9187 } ) ;
9288
93- debug ( 'creating new window' ) ;
89+ debug ( 'creating new window: ' + opts . url ) ;
9490 var _window = new BrowserWindow ( {
9591 width : opts . width ,
9692 height : opts . height ,
@@ -118,19 +114,6 @@ module.exports.create = function(opts) {
118114 } ) ;
119115 } ) ;
120116
121- if ( isConnectDialog ( opts . url ) ) {
122- AppMenu . hideConnect ( _window ) ;
123- connectWindow = _window ;
124- connectWindow . on ( 'focus' , function ( ) {
125- debug ( 'connect window focused.' ) ;
126- connectWindow . webContents . send ( 'message' , 'connect-window-focused' ) ;
127- } ) ;
128- connectWindow . on ( 'closed' , function ( ) {
129- debug ( 'connect window closed.' ) ;
130- connectWindow = null ;
131- } ) ;
132- }
133-
134117 // @see `all-windows-closed` above
135118 windowsOpenCount ++ ;
136119 _window . on ( 'closed' , function ( ) {
@@ -144,19 +127,18 @@ module.exports.create = function(opts) {
144127 return _window ;
145128} ;
146129
147- app . on ( 'show connect dialog' , function ( opts ) {
148- if ( connectWindow ) {
149- connectWindow . focus ( ) ;
150- return connectWindow ;
151- }
152-
153- opts = opts || { } ;
154- opts = _ . extend ( opts || { } , {
130+ function createWindow ( opts , url ) {
131+ opts = _ . extend ( opts , {
155132 width : config . windows . DEFAULT_WIDTH_DIALOG ,
156133 height : config . windows . DEFAULT_HEIGHT_DIALOG ,
157- url : DEFAULT_URL
134+ url : url
158135 } ) ;
159- module . exports . create ( opts ) ;
136+ return module . exports . create ( opts ) ;
137+ }
138+
139+ app . on ( 'close connect' , function ( ) {
140+ connectWindow . close ( ) ;
141+ connectWindow = null ;
160142} ) ;
161143
162144app . on ( 'show about dialog' , function ( ) {
@@ -167,8 +149,17 @@ app.on('show about dialog', function() {
167149 } ) ;
168150} ) ;
169151
170- app . on ( 'hide connect submenu' , function ( ) {
171- AppMenu . hideConnect ( ) ;
152+ app . on ( 'show connect dialog' , function ( ) {
153+ if ( connectWindow ) {
154+ connectWindow . focus ( ) ;
155+ return connectWindow ;
156+ }
157+
158+ connectWindow = createWindow ( { } , DEFAULT_URL ) ;
159+ connectWindow . on ( 'focus' , function ( ) {
160+ debug ( 'connect window focused.' ) ;
161+ connectWindow . webContents . send ( 'message' , 'connect-window-focused' ) ;
162+ } ) ;
172163} ) ;
173164
174165app . on ( 'hide share submenu' , function ( ) {
@@ -179,10 +170,6 @@ app.on('show compass overview submenu', function() {
179170 AppMenu . showCompassOverview ( ) ;
180171} ) ;
181172
182- app . on ( 'show connect submenu' , function ( ) {
183- AppMenu . showConnect ( ) ;
184- } ) ;
185-
186173app . on ( 'show share submenu' , function ( ) {
187174 AppMenu . showShare ( ) ;
188175} ) ;
0 commit comments