|
@@ -4,6 +4,7 @@ import $ from 'jquery';
|
|
export class DOMInput extends Input{
|
|
export class DOMInput extends Input{
|
|
|
|
|
|
constructor (element) {
|
|
constructor (element) {
|
|
|
|
+ super();
|
|
this.el = $(element);
|
|
this.el = $(element);
|
|
this.listeners = [];
|
|
this.listeners = [];
|
|
this.setupEvents();
|
|
this.setupEvents();
|
|
@@ -21,24 +22,11 @@ export class DOMInput extends Input{
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- registerListener (listener) {
|
|
|
|
- if(!listener.notify) {
|
|
|
|
- throw new Error("InternalError: Input listener must implement a notify function.");
|
|
|
|
- }
|
|
|
|
- this.listeners.push(listener);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
requestInput (callback) {
|
|
requestInput (callback) {
|
|
this.listeners.push(callback);
|
|
this.listeners.push(callback);
|
|
this.el.focus();
|
|
this.el.focus();
|
|
}
|
|
}
|
|
|
|
|
|
- removeListener (listener) {
|
|
|
|
- const idx = this.listeners.indexOf(listener);
|
|
|
|
- if (idx)
|
|
|
|
- this.listeners.splice(idx, 1);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
notifyInput (text) {
|
|
notifyInput (text) {
|
|
this.listeners.forEach(resolve => {
|
|
this.listeners.forEach(resolve => {
|
|
resolve(l);
|
|
resolve(l);
|