1 | const EventEmitter = require('events').EventEmitter
|
2 | const inherits = require('inherits')
|
3 |
|
4 | module.exports = Button
|
5 | inherits(Button, EventEmitter)
|
6 |
|
7 | function Button (opts) {
|
8 | if (!(this instanceof Button)) return new Button(opts)
|
9 |
|
10 | var input = opts.container.querySelector('.settings-panel-button');
|
11 | if (!input) {
|
12 | this.element = input = opts.container.appendChild(document.createElement('button'))
|
13 | input.className = 'settings-panel-button';
|
14 | input.addEventListener('click', (e) => {
|
15 | e.preventDefault();
|
16 | this.emit('input');
|
17 | })
|
18 | }
|
19 |
|
20 | this.update(opts);
|
21 | }
|
22 |
|
23 | Button.prototype.update = function (opts) {
|
24 | this.element.innerHTML = opts.value || opts.label;
|
25 | return this;
|
26 | };
|
27 |
|
28 | Button.prototype.label = false; |
\ | No newline at end of file |