@@ -144,10 +144,16 @@ define(function (require, exports, module) {
144144 $edgeButtonBallast ,
145145 $firefoxButtonBallast ,
146146 $panelTitle ,
147- $modeBtn ;
147+ $modeBtn ,
148+ $previewBtn ;
148149
149150 let customLivePreviewBannerShown = false ;
150151
152+ // so this variable stores the mode that was previously selected
153+ // this is needed when the preview mode (play button icon) is clicked, we store the current mode
154+ // so that when user unclicks the button we can revert back to the mode that was originally selected
155+ let modeThatWasSelected = null ;
156+
151157 StaticServer . on ( EVENT_EMBEDDED_IFRAME_WHO_AM_I , function ( ) {
152158 if ( $iframe && $iframe [ 0 ] ) {
153159 const iframeDom = $iframe [ 0 ] ;
@@ -264,10 +270,13 @@ define(function (require, exports, module) {
264270 // apply the effective mode
265271 if ( effectiveMode === "highlight" ) {
266272 _LPHighlightMode ( ) ;
273+ $previewBtn . removeClass ( 'selected' ) ;
267274 } else if ( effectiveMode === "edit" && isEditFeaturesActive ) {
268275 _LPEditMode ( ) ;
276+ $previewBtn . removeClass ( 'selected' ) ;
269277 } else {
270278 _LPPreviewMode ( ) ;
279+ $previewBtn . addClass ( 'selected' ) ;
271280 }
272281
273282 _updateModeButton ( effectiveMode ) ;
@@ -581,11 +590,35 @@ define(function (require, exports, module) {
581590 }
582591 }
583592
593+ /**
594+ * This function is called when user clicks the preview mode button (play button icon)
595+ * when this button is clicked we switch the mode button dropdown to preview mode
596+ */
597+ function _handlePreviewBtnClick ( ) {
598+ if ( $previewBtn . hasClass ( 'selected' ) ) {
599+ $previewBtn . removeClass ( 'selected' ) ;
600+ const isEditFeaturesActive = LiveDevelopment . isLPEditFeaturesActive ;
601+ if ( modeThatWasSelected ) {
602+ if ( modeThatWasSelected === 'edit' && ! isEditFeaturesActive ) {
603+ // we just set the preference as preference has change handlers that will update the config
604+ PreferencesManager . set ( PREFERENCE_LIVE_PREVIEW_MODE , "highlight" ) ;
605+ } else {
606+ PreferencesManager . set ( PREFERENCE_LIVE_PREVIEW_MODE , modeThatWasSelected ) ;
607+ }
608+ }
609+ } else {
610+ $previewBtn . addClass ( 'selected' ) ;
611+ modeThatWasSelected = PreferencesManager . get ( PREFERENCE_LIVE_PREVIEW_MODE ) ;
612+ PreferencesManager . set ( PREFERENCE_LIVE_PREVIEW_MODE , "preview" ) ;
613+ }
614+ }
615+
584616 async function _createExtensionPanel ( ) {
585617 let templateVars = {
586618 Strings : Strings ,
587619 livePreview : Strings . LIVE_DEV_STATUS_TIP_OUT_OF_SYNC ,
588620 clickToReload : Strings . LIVE_DEV_CLICK_TO_RELOAD_PAGE ,
621+ clickToPreview : Strings . LIVE_PREVIEW_MODE_PREVIEW ,
589622 livePreviewSettings : Strings . LIVE_DEV_SETTINGS ,
590623 livePreviewConfigureModes : Strings . LIVE_PREVIEW_CONFIGURE_MODES ,
591624 clickToPopout : Strings . LIVE_DEV_CLICK_POPOUT ,
@@ -616,6 +649,7 @@ define(function (require, exports, module) {
616649 $panelTitle = $panel . find ( "#panel-live-preview-title" ) ;
617650 $settingsIcon = $panel . find ( "#livePreviewSettingsBtn" ) ;
618651 $modeBtn = $panel . find ( "#livePreviewModeBtn" ) ;
652+ $previewBtn = $panel . find ( "#previewModeLivePreviewButton" ) ;
619653
620654 $panel . find ( ".live-preview-settings-banner-btn" ) . on ( "click" , ( ) => {
621655 CommandManager . execute ( Commands . FILE_LIVE_FILE_PREVIEW_SETTINGS ) ;
@@ -650,6 +684,7 @@ define(function (require, exports, module) {
650684 } ) ;
651685
652686 $modeBtn . on ( "click" , _showModeSelectionDropdown ) ;
687+ $previewBtn . on ( "click" , _handlePreviewBtnClick ) ;
653688
654689 _showOpenBrowserIcons ( ) ;
655690 $settingsIcon . click ( ( ) => {
@@ -1063,10 +1098,13 @@ define(function (require, exports, module) {
10631098
10641099 if ( effectiveMode === "highlight" ) {
10651100 _LPHighlightMode ( ) ;
1101+ $previewBtn . removeClass ( 'selected' ) ;
10661102 } else if ( effectiveMode === "edit" && isEditFeaturesActive ) {
10671103 _LPEditMode ( ) ;
1104+ $previewBtn . removeClass ( 'selected' ) ;
10681105 } else {
10691106 _LPPreviewMode ( ) ;
1107+ $previewBtn . addClass ( 'selected' ) ;
10701108 }
10711109
10721110 _updateModeButton ( effectiveMode ) ;
0 commit comments