@@ -140,18 +140,6 @@ define(function (require, exports, module) {
140140 /** @type {Object } Map of panelID -> minSize for bottom panels */
141141 let _panelMinSizes = { } ;
142142
143- /** Fallback title map for panels that don't have a .toolbar .title element */
144- const _KNOWN_PANEL_TITLES = {
145- "errors" : "Problems" ,
146- "problems-panel" : "Problems" ,
147- "search-results" : "Search Results" ,
148- "find-in-files-results" : "Search Results" ,
149- "references-panel" : "References" ,
150- "git-panel" : "Git" ,
151- "keyboard-shortcuts-panel" : "Keyboard Shortcuts" ,
152- "custom-snippets-panel" : "Custom Snippets" ,
153- "test-builder-panel" : "Test Builder"
154- } ;
155143
156144
157145 /**
@@ -260,27 +248,17 @@ define(function (require, exports, module) {
260248
261249 /**
262250 * Resolve the display title for a bottom panel tab.
263- * First looks for a .toolbar .title element within the panel DOM,
264- * then falls back to the _KNOWN_PANEL_TITLES map using the panel's DOM id.
251+ * Uses the explicit title if provided, otherwise humanizes the panel id.
265252 * @param {string } id The panel registration ID
266- * @param {jQueryObject } $panel The panel's jQuery element
253+ * @param {string= } title Explicit title passed to createBottomPanel
267254 * @return {string }
268255 * @private
269256 */
270- function _getPanelTitle ( id , $panel ) {
271- let $titleEl = $panel . find ( ".toolbar .title" ) ;
272- if ( $titleEl . length && $ . trim ( $titleEl . text ( ) ) ) {
273- return $ . trim ( $titleEl . text ( ) ) ;
257+ function _getPanelTitle ( id , title ) {
258+ if ( title ) {
259+ return title ;
274260 }
275- let domId = $panel . attr ( "id" ) || "" ;
276- if ( _KNOWN_PANEL_TITLES [ domId ] ) {
277- return _KNOWN_PANEL_TITLES [ domId ] ;
278- }
279- if ( _KNOWN_PANEL_TITLES [ id ] ) {
280- return _KNOWN_PANEL_TITLES [ id ] ;
281- }
282- // Last resort: humanize the id
283- let label = ( domId || id ) . replace ( / [ - _ ] / g, " " ) ;
261+ let label = id . replace ( new RegExp ( "[-_.]" , "g" ) , " " ) . split ( " " ) [ 0 ] ;
284262 return label . charAt ( 0 ) . toUpperCase ( ) + label . slice ( 1 ) ;
285263 }
286264
@@ -301,7 +279,7 @@ define(function (require, exports, module) {
301279 if ( ! panel ) {
302280 return ;
303281 }
304- let title = panel . _tabTitle || _getPanelTitle ( panelId , panel . $panel ) ;
282+ let title = panel . _tabTitle || _getPanelTitle ( panelId ) ;
305283 let isActive = ( panelId === _activeBottomPanelId ) ;
306284 let $tab = $ ( '<div class="bottom-panel-tab' + ( isActive ? ' active' : '' ) + '" data-panel-id="' + panelId + '">' +
307285 '<span class="bottom-panel-tab-title">' + $ ( "<span>" ) . text ( title ) . html ( ) + '</span>' +
@@ -368,9 +346,10 @@ define(function (require, exports, module) {
368346 * @param {!jQueryObject } $panel DOM content to use as the panel. Need not be in the document yet. Must have an id
369347 * attribute, for use as a preferences key.
370348 * @param {number= } minSize Minimum height of panel in px.
349+ * @param {string= } title Display title shown in the bottom panel tab bar.
371350 * @return {!Panel }
372351 */
373- function createBottomPanel ( id , $panel , minSize ) {
352+ function createBottomPanel ( id , $panel , minSize , title ) {
374353 // Insert panel into the tabbed container instead of before #status-bar
375354 $bottomPanelContainer . append ( $panel ) ;
376355 $panel . hide ( ) ;
@@ -383,7 +362,7 @@ define(function (require, exports, module) {
383362 panelIDMap [ id ] = bottomPanel ;
384363
385364 // Cache the tab title at creation time
386- bottomPanel . _tabTitle = _getPanelTitle ( id , $panel ) ;
365+ bottomPanel . _tabTitle = _getPanelTitle ( id , title ) ;
387366
388367 // Do NOT call Resizer.makeResizable on individual panels.
389368 // The container handles resizing.
0 commit comments