Promisify getStatusBarTemplate method

This commit is contained in:
Yukai Huang 2017-03-28 15:24:52 +08:00
parent af5ef52f4b
commit 46ed658d8b

View file

@ -131,38 +131,40 @@ export default class Editor {
}) })
} }
getStatusBarTemplate (callback) { getStatusBarTemplate () {
$.get(window.serverurl + '/views/statusbar.html', template => { return new Promise((resolve, reject) => {
this.statusBarTemplate = template $.get(window.serverurl + '/views/statusbar.html').done(template => {
if (callback) callback() this.statusBarTemplate = template
resolve()
}).fail(reject)
}) })
} }
addStatusBar () { addStatusBar () {
if (!this.statusBarTemplate) { if (!this.statusBarTemplate) {
this.getStatusBarTemplate(this.addStatusBar) this.getStatusBarTemplate.then(this.addStatusBar)
return } else {
} this.statusBar = $(this.statusBarTemplate)
this.statusBar = $(this.statusBarTemplate) this.statusCursor = this.statusBar.find('.status-cursor > .status-line-column')
this.statusCursor = this.statusBar.find('.status-cursor > .status-line-column') this.statusSelection = this.statusBar.find('.status-cursor > .status-selection')
this.statusSelection = this.statusBar.find('.status-cursor > .status-selection') this.statusFile = this.statusBar.find('.status-file')
this.statusFile = this.statusBar.find('.status-file') this.statusIndicators = this.statusBar.find('.status-indicators')
this.statusIndicators = this.statusBar.find('.status-indicators') this.statusIndent = this.statusBar.find('.status-indent')
this.statusIndent = this.statusBar.find('.status-indent') this.statusKeymap = this.statusBar.find('.status-keymap')
this.statusKeymap = this.statusBar.find('.status-keymap') this.statusLength = this.statusBar.find('.status-length')
this.statusLength = this.statusBar.find('.status-length') this.statusTheme = this.statusBar.find('.status-theme')
this.statusTheme = this.statusBar.find('.status-theme') this.statusSpellcheck = this.statusBar.find('.status-spellcheck')
this.statusSpellcheck = this.statusBar.find('.status-spellcheck') this.statusPreferences = this.statusBar.find('.status-preferences')
this.statusPreferences = this.statusBar.find('.status-preferences') this.statusPanel = this.editor.addPanel(this.statusBar[0], {
this.statusPanel = this.editor.addPanel(this.statusBar[0], { position: 'bottom'
position: 'bottom' })
})
this.setIndent() this.setIndent()
this.setKeymap() this.setKeymap()
this.setTheme() this.setTheme()
this.setSpellcheck() this.setSpellcheck()
this.setPreferences() this.setPreferences()
}
} }
setIndent () { setIndent () {