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) { getStatusBarTemplate () {
$.get(window.serverurl + '/views/statusbar.html', template => { return new Promise((resolve, reject) => {
$.get(window.serverurl + '/views/statusbar.html').done(template => {
this.statusBarTemplate = template this.statusBarTemplate = template
if (callback) callback() 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')
@ -164,6 +165,7 @@ export default class Editor {
this.setSpellcheck() this.setSpellcheck()
this.setPreferences() this.setPreferences()
} }
}
setIndent () { setIndent () {
var cookieIndentType = Cookies.get('indent_type') var cookieIndentType = Cookies.get('indent_type')