-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathbutton.js
35 lines (27 loc) · 864 Bytes
/
button.js
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
var EventEmitter = require('events').EventEmitter
var inherits = require('inherits')
var css = require('dom-css')
module.exports = Button
inherits(Button, EventEmitter)
function Button (root, opts, theme, uuid) {
if (!(this instanceof Button)) return new Button(root, opts, theme, uuid)
var container = require('./container')(root, opts.label)
require('./label')(container, '', theme)
var input = container.appendChild(document.createElement('button'))
input.className = 'control-panel-button-' + uuid
input.onfocus = function () {
css(input, {outline: 'none'})
}
input.textContent = opts.label
css(input, {
position: 'absolute',
textAlign: 'center',
height: '20px',
width: '62%',
border: 'none',
cursor: 'pointer',
right: 0,
fontFamily: 'inherit'
})
input.addEventListener('click', opts.action)
}