@@ -269,6 +269,62 @@ define(function main(require, exports, module) {
269269 return false ;
270270 }
271271
272+ let $livePreviewPanel = null ; // stores the live preview panel, need this as overlay is appended inside this
273+ let $overlayContainer = null ; // the overlay container
274+
275+ /**
276+ * this function is responsible to show the overlay.
277+ * so overlay is shown when the live preview is connecting or live preview stopped because of some syntax error
278+ * @param {String } textMessage - the text that is written inside the overlay
279+ */
280+ function _showOverlay ( textMessage ) {
281+ if ( ! $livePreviewPanel ) {
282+ $livePreviewPanel = $ ( "#panel-live-preview" ) ;
283+ }
284+
285+ // remove any existing overlay
286+ _hideOverlay ( ) ;
287+
288+ // create the overlay element
289+ // styled inside the 'src/extensionsIntegrated/Phoenix-live-preview/live-preview.css'
290+ $overlayContainer = $ ( "<div>" ) . addClass ( "live-preview-status-overlay" ) ; // the wrapper for overlay element
291+ const $message = $ ( "<div>" ) . addClass ( "live-preview-overlay-message" ) . text ( textMessage ) ;
292+
293+ $overlayContainer . append ( $message ) ;
294+ $livePreviewPanel . append ( $overlayContainer ) ;
295+ }
296+
297+ /**
298+ * responsible to hide the overlay
299+ */
300+ function _hideOverlay ( ) {
301+ if ( $overlayContainer ) {
302+ $overlayContainer . remove ( ) ;
303+ $overlayContainer = null ;
304+ }
305+ }
306+
307+ /**
308+ * this function adds/remove the full-width class from the overlay container
309+ * styled inside 'src/extensionsIntegrated/Phoenix-live-preview/live-preview.css'
310+ *
311+ * we need this because
312+ * normally when live preview has a good width (more than 305px) then a 3px divider is shown at the left end
313+ * so in that case we give the overlay a width of (100% - 3px),
314+ * but when the live preview width is reduced
315+ * then that divider line gets cut off, so in that case we make the width 100% for this overlay
316+ *
317+ * without this handling, a white gap appears on the left side, which is distracting
318+ */
319+ function _setOverlayWidth ( ) {
320+ if ( ! $overlayContainer || ! $livePreviewPanel . length ) { return ; }
321+ if ( $livePreviewPanel . width ( ) <= 305 ) {
322+ $overlayContainer . addClass ( "full-width" ) ;
323+ } else {
324+ $overlayContainer . removeClass ( "full-width" ) ;
325+ }
326+ }
327+
272328 /** Initialize LiveDevelopment */
273329 AppInit . appReady ( function ( ) {
274330 params . parse ( ) ;
@@ -323,6 +379,18 @@ define(function main(require, exports, module) {
323379 exports . trigger ( exports . EVENT_LIVE_PREVIEW_RELOAD , clientDetails ) ;
324380 } ) ;
325381
382+ MultiBrowserLiveDev . on ( MultiBrowserLiveDev . EVENT_STATUS_CHANGE , function ( event , status ) {
383+ if ( status === MultiBrowserLiveDev . STATUS_CONNECTING ) {
384+ _showOverlay ( Strings . LIVE_DEV_STATUS_TIP_PROGRESS1 ) ;
385+ } else if ( status === MultiBrowserLiveDev . STATUS_SYNC_ERROR ) {
386+ _showOverlay ( Strings . LIVE_DEV_STATUS_TIP_SYNC_ERROR ) ;
387+ } else {
388+ _hideOverlay ( ) ;
389+ }
390+ } ) ;
391+ // to understand why we need this, pls read the _setOverlayWidth function
392+ new ResizeObserver ( _setOverlayWidth ) . observe ( $ ( "#main-plugin-panel" ) [ 0 ] ) ;
393+
326394 // allow live preview to handle escape key event
327395 // Escape is mainly to hide boxes if they are visible
328396 WorkspaceManager . addEscapeKeyEventHandler ( "livePreview" , _handleLivePreviewEscapeKey ) ;
0 commit comments