1 Star 0 Fork 41

YT/GitCodeTree

forked from 开源中国/GiteeTree 
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
view.error.js 1.21 KB
Copy Edit Raw Blame History
Buu Nguyen authored 2015-11-15 14:53 +08:00 . Fix bug showing/saving in error view
class ErrorView {
constructor($dom, store) {
this.store = store
this.$view = $dom
.find('.octotree_errorview')
.submit(this._saveToken.bind(this))
}
show(err) {
const $token = this.$view.find('input[name="token"]')
const $submit = this.$view.find('button[type="submit"]')
const $help = $submit.next()
const token = this.store.get(STORE.TOKEN)
this.$view.find('.octotree_view_header').html(err.error)
this.$view.find('.message').html(err.message)
if (err.needAuth) {
$submit.show()
$token.show()
$help.show()
if (token) $token.val(token)
}
else {
$submit.hide()
$token.hide()
$help.hide()
}
$(this).trigger(EVENT.VIEW_READY)
}
_saveToken(event) {
event.preventDefault()
const $error = this.$view.find('.error').text('')
const $token = this.$view.find('[name="token"]')
const oldToken = this.store.get(STORE.TOKEN)
const newToken = $token.val()
if (!newToken) return $error.text('Token is required')
this.store.set(STORE.TOKEN, newToken, () => {
const changes = {[STORE.TOKEN]: [oldToken, newToken]}
$(this).trigger(EVENT.OPTS_CHANGE, changes)
$token.val('')
})
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/YT_Unity/GitCodeTree.git
git@gitee.com:YT_Unity/GitCodeTree.git
YT_Unity
GitCodeTree
GitCodeTree
master

Search