@@ -274,26 +274,48 @@ define(function main(require, exports, module) {
274274
275275 let $livePreviewPanel = null ; // stores the live preview panel, need this as overlay is appended inside this
276276 let $overlayContainer = null ; // the overlay container
277+ let shouldShowSyncErrorOverlay = true ; // once user closes the overlay we don't show them again
278+ let shouldShowConnectingOverlay = true ;
277279
278280 /**
279281 * this function is responsible to show the overlay.
280282 * so overlay is shown when the live preview is connecting or live preview stopped because of some syntax error
281283 * @param {String } textMessage - the text that is written inside the overlay
284+ * @param {Number } status - 1 for connect, 4 for sync error but we match it using MultiBrowserLiveDev
282285 */
283- function _showOverlay ( textMessage ) {
286+ function _showOverlay ( textMessage , status ) {
284287 if ( ! $livePreviewPanel ) {
285288 $livePreviewPanel = $ ( "#panel-live-preview" ) ;
286289 }
287290
288291 // remove any existing overlay
289292 _hideOverlay ( ) ;
290293
294+ // to not show the overlays if user has already closed it before
295+ if ( status === MultiBrowserLiveDev . STATUS_CONNECTING && ! shouldShowConnectingOverlay ) { return ; }
296+ if ( status === MultiBrowserLiveDev . STATUS_SYNC_ERROR && ! shouldShowSyncErrorOverlay ) { return ; }
297+
291298 // create the overlay element
292299 // styled inside the 'src/extensionsIntegrated/Phoenix-live-preview/live-preview.css'
293300 $overlayContainer = $ ( "<div>" ) . addClass ( "live-preview-status-overlay" ) ; // the wrapper for overlay element
294301 const $message = $ ( "<div>" ) . addClass ( "live-preview-overlay-message" ) . text ( textMessage ) ;
295302
303+ // the close button at the right end of the overlay
304+ const $close = $ ( "<div>" ) . addClass ( "live-preview-overlay-close" )
305+ . attr ( "title" , Strings . LIVE_PREVIEW_HIDE_OVERLAY )
306+ . on ( 'click' , ( ) => {
307+ if ( status === MultiBrowserLiveDev . STATUS_CONNECTING ) {
308+ shouldShowConnectingOverlay = false ;
309+ } else if ( status === MultiBrowserLiveDev . STATUS_SYNC_ERROR ) {
310+ shouldShowSyncErrorOverlay = false ;
311+ }
312+ _hideOverlay ( ) ;
313+ } ) ;
314+ const $closeIcon = $ ( "<i>" ) . addClass ( "fas fa-times" ) ;
315+
316+ $close . append ( $closeIcon ) ;
296317 $overlayContainer . append ( $message ) ;
318+ $overlayContainer . append ( $close ) ;
297319 $livePreviewPanel . append ( $overlayContainer ) ;
298320 }
299321
@@ -384,9 +406,9 @@ define(function main(require, exports, module) {
384406
385407 MultiBrowserLiveDev . on ( MultiBrowserLiveDev . EVENT_STATUS_CHANGE , function ( event , status ) {
386408 if ( status === MultiBrowserLiveDev . STATUS_CONNECTING ) {
387- _showOverlay ( Strings . LIVE_DEV_STATUS_TIP_PROGRESS1 ) ;
409+ _showOverlay ( Strings . LIVE_DEV_STATUS_TIP_PROGRESS1 , status ) ;
388410 } else if ( status === MultiBrowserLiveDev . STATUS_SYNC_ERROR ) {
389- _showOverlay ( Strings . LIVE_DEV_STATUS_TIP_SYNC_ERROR ) ;
411+ _showOverlay ( Strings . LIVE_DEV_STATUS_TIP_SYNC_ERROR , status ) ;
390412 } else {
391413 _hideOverlay ( ) ;
392414 }
0 commit comments