-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompose-shell-button.js
More file actions
45 lines (42 loc) · 1.11 KB
/
compose-shell-button.js
File metadata and controls
45 lines (42 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var template = require('./templates/button.hbs')
xtag.register('compose-shell-button', {
lifecycle: {
created: function(){
this.type = this.getAttribute('type')
this.innerHTML = template({
enabled: this.enabled,
type: this.type,
content: this.textContent
})
},
inserted: function(){
if (this.type !== 'submit')
this.shell.registerButton(this)
}
},
events: {
'click:delegate(button)': function(event) {
var button = event.currentTarget
button.children[0].blur()
if (button.type === 'submit')
return
event.preventDefault()
event.currentTarget.enabled = !event.currentTarget.enabled
xtag.fireEvent(button, 'toggle')
}
},
accessors: {
enabled: {
get: function(){ return !!this.getAttribute('enabled') },
set: function(enabled){
if (enabled === true)
this.setAttribute('enabled', true)
else if (enabled === false)
this.removeAttribute('enabled')
}
},
toggle: {
get: function(){ return this.getAttribute('toggle') }
}
}
})