Skip to content

Commit 46ed658

Browse files
committed
Promisify getStatusBarTemplate method
1 parent af5ef52 commit 46ed658

1 file changed

Lines changed: 28 additions & 26 deletions

File tree

public/js/lib/editor/index.js

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -131,38 +131,40 @@ export default class Editor {
131131
})
132132
}
133133

134-
getStatusBarTemplate (callback) {
135-
$.get(window.serverurl + '/views/statusbar.html', template => {
136-
this.statusBarTemplate = template
137-
if (callback) callback()
134+
getStatusBarTemplate () {
135+
return new Promise((resolve, reject) => {
136+
$.get(window.serverurl + '/views/statusbar.html').done(template => {
137+
this.statusBarTemplate = template
138+
resolve()
139+
}).fail(reject)
138140
})
139141
}
140142

141143
addStatusBar () {
142144
if (!this.statusBarTemplate) {
143-
this.getStatusBarTemplate(this.addStatusBar)
144-
return
145-
}
146-
this.statusBar = $(this.statusBarTemplate)
147-
this.statusCursor = this.statusBar.find('.status-cursor > .status-line-column')
148-
this.statusSelection = this.statusBar.find('.status-cursor > .status-selection')
149-
this.statusFile = this.statusBar.find('.status-file')
150-
this.statusIndicators = this.statusBar.find('.status-indicators')
151-
this.statusIndent = this.statusBar.find('.status-indent')
152-
this.statusKeymap = this.statusBar.find('.status-keymap')
153-
this.statusLength = this.statusBar.find('.status-length')
154-
this.statusTheme = this.statusBar.find('.status-theme')
155-
this.statusSpellcheck = this.statusBar.find('.status-spellcheck')
156-
this.statusPreferences = this.statusBar.find('.status-preferences')
157-
this.statusPanel = this.editor.addPanel(this.statusBar[0], {
158-
position: 'bottom'
159-
})
145+
this.getStatusBarTemplate.then(this.addStatusBar)
146+
} else {
147+
this.statusBar = $(this.statusBarTemplate)
148+
this.statusCursor = this.statusBar.find('.status-cursor > .status-line-column')
149+
this.statusSelection = this.statusBar.find('.status-cursor > .status-selection')
150+
this.statusFile = this.statusBar.find('.status-file')
151+
this.statusIndicators = this.statusBar.find('.status-indicators')
152+
this.statusIndent = this.statusBar.find('.status-indent')
153+
this.statusKeymap = this.statusBar.find('.status-keymap')
154+
this.statusLength = this.statusBar.find('.status-length')
155+
this.statusTheme = this.statusBar.find('.status-theme')
156+
this.statusSpellcheck = this.statusBar.find('.status-spellcheck')
157+
this.statusPreferences = this.statusBar.find('.status-preferences')
158+
this.statusPanel = this.editor.addPanel(this.statusBar[0], {
159+
position: 'bottom'
160+
})
160161

161-
this.setIndent()
162-
this.setKeymap()
163-
this.setTheme()
164-
this.setSpellcheck()
165-
this.setPreferences()
162+
this.setIndent()
163+
this.setKeymap()
164+
this.setTheme()
165+
this.setSpellcheck()
166+
this.setPreferences()
167+
}
166168
}
167169

168170
setIndent () {

0 commit comments

Comments
 (0)