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,18 +131,19 @@ export default class Editor {
})
}
getStatusBarTemplate (callback) {
$.get(window.serverurl + '/views/statusbar.html', template => {
getStatusBarTemplate () {
return new Promise((resolve, reject) => {
$.get(window.serverurl + '/views/statusbar.html').done(template => {
this.statusBarTemplate = template
if (callback) callback()
resolve()
}).fail(reject)
})
}
addStatusBar () {
if (!this.statusBarTemplate) {
this.getStatusBarTemplate(this.addStatusBar)
return
}
this.getStatusBarTemplate.then(this.addStatusBar)
} else {
this.statusBar = $(this.statusBarTemplate)
this.statusCursor = this.statusBar.find('.status-cursor > .status-line-column')
this.statusSelection = this.statusBar.find('.status-cursor > .status-selection')
@ -164,6 +165,7 @@ export default class Editor {
this.setSpellcheck()
this.setPreferences()
}
}
setIndent () {
var cookieIndentType = Cookies.get('indent_type')