1+ /* global CodeMirror, $ */
12import Storage from './storage'
23import { availableThemes } from './constants'
3- import { defaultEditorMode , jumpToAddressBarKeymapName } from './editor-config'
4- import debounce from 'lodash/debounce'
5-
4+ import { jumpToAddressBarKeymapName } from './editor-config'
65export default class StatusBar {
7- constructor ( editor , config ) {
6+ constructor ( editor , config ) {
87 this . editor = editor
98 this . config = config
109 this . statusBar = null
@@ -23,7 +22,7 @@ export default class StatusBar {
2322 this . jumpToAddressBarKeymapValue = null
2423 }
2524
26- init ( template ) {
25+ init ( template ) {
2726 this . statusBar = $ ( template )
2827 this . statusCursor = this . statusBar . find ( '.status-cursor > .status-line-column' )
2928 this . statusSelection = this . statusBar . find ( '.status-cursor > .status-selection' )
@@ -55,37 +54,37 @@ export default class StatusBar {
5554 return this . statusBar
5655 }
5756
58- handleResize ( ) {
57+ handleResize ( ) {
5958 // Resize handling is now managed by Editor class
6059 }
6160
62- getHeight ( ) {
61+ getHeight ( ) {
6362 return this . statusBar ? this . statusBar [ 0 ] . offsetHeight : 0
6463 }
6564
66- setDropdownMaxHeight ( maxHeight ) {
65+ setDropdownMaxHeight ( maxHeight ) {
6766 if ( this . statusBar ) {
6867 this . statusBar . find ( '.status-theme ul.dropdown-menu' ) . css ( 'max-height' , `${ maxHeight } px` )
6968 }
7069 }
7170
72- update ( ) {
71+ update ( ) {
7372 if ( ! this . statusBar ) return
7473
7574 const cursor = this . editor . getCursor ( )
7675 const cursorText = `Line ${ cursor . line + 1 } , Column ${ cursor . ch + 1 } `
7776 this . statusCursor . text ( cursorText )
78-
77+
7978 const fileText = ` — ${ this . editor . lineCount ( ) } Lines`
8079 this . statusFile . text ( fileText )
81-
80+
8281 const docLength = this . editor . getValue ( ) . length
8382 this . statusLength . text ( `Length ${ docLength } ` )
8483
8584 this . updateLengthIndicator ( docLength )
8685 }
8786
88- updateLengthIndicator ( docLength ) {
87+ updateLengthIndicator ( docLength ) {
8988 if ( docLength > ( this . config . docmaxlength * 0.95 ) ) {
9089 this . statusLength . css ( 'color' , 'red' )
9190 this . statusLength . attr ( 'title' , 'You have almost reached the limit for this document.' )
@@ -98,9 +97,9 @@ export default class StatusBar {
9897 }
9998 }
10099
101- setupThemeDropdown ( ) {
100+ setupThemeDropdown ( ) {
102101 this . statusIndicators . find ( '.status-theme ul.dropdown-menu' ) . append (
103- availableThemes . map ( theme =>
102+ availableThemes . map ( theme =>
104103 $ ( `<li value="${ theme . value } "><a>${ theme . name } </a></li>` )
105104 )
106105 )
@@ -116,14 +115,14 @@ export default class StatusBar {
116115 } )
117116 }
118117
119- setTheme ( theme ) {
118+ setTheme ( theme ) {
120119 this . editor . setOption ( 'theme' , theme )
121120 Storage . set ( 'theme' , theme )
122121 this . statusIndicators . find ( '.status-theme li' ) . removeClass ( 'active' )
123122 this . statusIndicators . find ( `.status-theme li[value="${ theme } "]` ) . addClass ( 'active' )
124123 }
125124
126- setupIndentation ( ) {
125+ setupIndentation ( ) {
127126 const storedIndentType = Storage . get ( 'indent_type' )
128127 const storedTabSize = parseInt ( Storage . get ( 'tab_size' ) )
129128 const storedSpaceUnits = parseInt ( Storage . get ( 'space_units' ) )
@@ -143,15 +142,15 @@ export default class StatusBar {
143142 this . setupIndentationHandlers ( )
144143 }
145144
146- setupIndentationHandlers ( ) {
145+ setupIndentationHandlers ( ) {
147146 const type = this . statusIndicators . find ( '.indent-type' )
148147 const widthLabel = this . statusIndicators . find ( '.indent-width-label' )
149148 const widthInput = this . statusIndicators . find ( '.indent-width-input' )
150149
151150 type . click ( ( ) => {
152151 const currentIndentWithTabs = this . editor . getOption ( 'indentWithTabs' )
153152 this . editor . setOption ( 'indentWithTabs' , ! currentIndentWithTabs )
154-
153+
155154 if ( ! currentIndentWithTabs ) {
156155 const storedTabSize = parseInt ( Storage . get ( 'tab_size' ) )
157156 if ( storedTabSize ) {
@@ -171,7 +170,7 @@ export default class StatusBar {
171170 this . setupIndentationWidthHandlers ( widthLabel , widthInput )
172171 }
173172
174- setupIndentationWidthHandlers ( widthLabel , widthInput ) {
173+ setupIndentationWidthHandlers ( widthLabel , widthInput ) {
175174 widthLabel . click ( ( ) => {
176175 if ( widthLabel . is ( ':visible' ) ) {
177176 widthLabel . addClass ( 'hidden' )
@@ -191,7 +190,7 @@ export default class StatusBar {
191190 }
192191 this . editor . setOption ( 'indentUnit' , val )
193192 Storage . set ( 'space_units' , val )
194-
193+
195194 this . updateIndentationDisplay ( )
196195 } )
197196
@@ -201,19 +200,19 @@ export default class StatusBar {
201200 } )
202201 }
203202
204- updateIndentationDisplay ( ) {
203+ updateIndentationDisplay ( ) {
205204 const type = this . statusIndicators . find ( '.indent-type' )
206205 const widthLabel = this . statusIndicators . find ( '.indent-width-label' )
207-
206+
208207 const indentWithTabs = this . editor . getOption ( 'indentWithTabs' )
209208 type . text ( indentWithTabs ? 'Tab Size:' : 'Spaces:' )
210209 Storage . set ( 'indent_type' , indentWithTabs ? 'tab' : 'space' )
211-
210+
212211 const unit = this . editor . getOption ( 'indentUnit' )
213212 widthLabel . text ( unit )
214213 }
215214
216- setupKeymap ( ) {
215+ setupKeymap ( ) {
217216 const storedKeymap = Storage . get ( 'keymap' )
218217 if ( storedKeymap ) {
219218 this . editor . setOption ( 'keyMap' , storedKeymap )
@@ -231,21 +230,21 @@ export default class StatusBar {
231230 vim . click ( ( ) => this . setKeymap ( 'vim' ) )
232231 }
233232
234- setKeymap ( keymap ) {
233+ setKeymap ( keymap ) {
235234 this . editor . setOption ( 'keyMap' , keymap )
236235 Storage . set ( 'keymap' , keymap )
237236 this . updateKeymapLabel ( )
238237 }
239238
240- updateKeymapLabel ( ) {
239+ updateKeymapLabel ( ) {
241240 const keymap = this . editor . getOption ( 'keyMap' )
242241 this . statusIndicators . find ( '.ui-keymap-label' ) . text ( keymap )
243242 }
244243
245- setupLinter ( ) {
244+ setupLinter ( ) {
246245 const linterToggle = this . statusLinter . find ( '.ui-linter-toggle' )
247246 const enable = Storage . get ( 'linter' ) === 'true'
248-
247+
249248 this . toggleLinter ( enable )
250249 linterToggle . toggleClass ( 'active' , enable )
251250
@@ -256,7 +255,7 @@ export default class StatusBar {
256255 } )
257256 }
258257
259- toggleLinter ( enable ) {
258+ toggleLinter ( enable ) {
260259 const gutters = this . editor . getOption ( 'gutters' )
261260 const lintGutter = 'CodeMirror-lint-markers'
262261
@@ -272,10 +271,10 @@ export default class StatusBar {
272271 this . editor . setOption ( 'lint' , enable ? this . config . linterOptions : false )
273272 }
274273
275- setupPreferences ( ) {
274+ setupPreferences ( ) {
276275 const overrideBrowserKeymap = $ ( '.ui-preferences-override-browser-keymap label > input[type="checkbox"]' )
277276 const storedOverrideBrowserKeymap = Storage . get ( 'preferences-override-browser-keymap' )
278-
277+
279278 overrideBrowserKeymap . prop ( 'checked' , storedOverrideBrowserKeymap === 'true' )
280279 this . setOverrideBrowserKeymap ( )
281280
@@ -284,7 +283,7 @@ export default class StatusBar {
284283 } )
285284 }
286285
287- setOverrideBrowserKeymap ( ) {
286+ setOverrideBrowserKeymap ( ) {
288287 const overrideBrowserKeymap = $ ( '.ui-preferences-override-browser-keymap label > input[type="checkbox"]' )
289288 if ( overrideBrowserKeymap . is ( ':checked' ) ) {
290289 Storage . set ( 'preferences-override-browser-keymap' , 'true' )
@@ -295,15 +294,15 @@ export default class StatusBar {
295294 }
296295 }
297296
298- resetEditorKeymapToBrowserKeymap ( ) {
297+ resetEditorKeymapToBrowserKeymap ( ) {
299298 const keymap = this . editor . getOption ( 'keyMap' )
300299 if ( ! this . jumpToAddressBarKeymapValue ) {
301300 this . jumpToAddressBarKeymapValue = CodeMirror . keyMap [ keymap ] [ jumpToAddressBarKeymapName ]
302301 delete CodeMirror . keyMap [ keymap ] [ jumpToAddressBarKeymapName ]
303302 }
304303 }
305304
306- restoreOverrideEditorKeymap ( ) {
305+ restoreOverrideEditorKeymap ( ) {
307306 const keymap = this . editor . getOption ( 'keyMap' )
308307 if ( this . jumpToAddressBarKeymapValue ) {
309308 CodeMirror . keyMap [ keymap ] [ jumpToAddressBarKeymapName ] = this . jumpToAddressBarKeymapValue
0 commit comments