@@ -79,26 +79,40 @@ abstract class SidebarBase extends JSDialogComponent {
7979 return node . hasClass ( 'visible' ) && node . hasClass ( 'coreBased' ) ;
8080 }
8181
82- closeSidebar ( ) {
83- $ ( `#${ this . type } -dock-wrapper` ) . removeClass ( 'visible' ) ;
84- $ ( `#${ this . type } -dock-wrapper` ) . removeClass ( 'coreBased' ) ;
82+ /// checks if this sidebar is core-based (uses WindowId.Sidebar)
83+ protected isCoreBased ( ) : boolean {
84+ return this . builder && ( this . builder as any ) . windowId === WindowId . Sidebar ;
85+ }
86+
87+ /// shared implementation for showing/hiding sidebar
88+ protected showSidebarImpl ( show : boolean ) {
89+ const wrapper = $ ( `#${ this . type } -dock-wrapper` ) ;
8590
86- if ( ! this . map . editorHasFocus ( ) ) {
87- this . map . fire ( 'editorgotfocus' ) ;
88- this . map . focus ( ) ;
91+ if ( show ) {
92+ wrapper . addClass ( 'visible' ) ;
93+ if ( this . isCoreBased ( ) ) {
94+ wrapper . addClass ( 'coreBased' ) ;
95+ }
96+ } else {
97+ wrapper . removeClass ( 'visible' ) ;
98+ wrapper . removeClass ( 'coreBased' ) ;
99+
100+ if ( ! this . map . editorHasFocus ( ) ) {
101+ this . map . fire ( 'editorgotfocus' ) ;
102+ this . map . focus ( ) ;
103+ }
89104 }
90105
91106 const upperCaseType = this . type [ 0 ] . toUpperCase ( ) + this . type . slice ( 1 ) ;
92- this . map . uiManager . setDocTypePref ( 'Show' + upperCaseType , false ) ;
107+ this . map . uiManager . setDocTypePref ( 'Show' + upperCaseType , show ) ;
93108 }
94109
95- showSidebar ( ) {
96- $ ( `#${ this . type } -dock-wrapper` ) . addClass ( 'visible' ) ;
97- if ( this . builder && ( this . builder as any ) . windowId === WindowId . Sidebar )
98- $ ( `#${ this . type } -dock-wrapper` ) . addClass ( 'coreBased' ) ;
110+ closeSidebar ( ) {
111+ this . showSidebarImpl ( false ) ;
112+ }
99113
100- const upperCaseType = this . type [ 0 ] . toUpperCase ( ) + this . type . slice ( 1 ) ;
101- this . map . uiManager . setDocTypePref ( 'Show' + upperCaseType , true ) ;
114+ showSidebar ( ) {
115+ this . showSidebarImpl ( true ) ;
102116 }
103117
104118 protected onJSUpdate ( e : FireEvent ) {
0 commit comments