From 98eaea0982303550eb816f5b417d6ae6ba81d19e Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sun, 22 Jan 2023 13:18:05 +0400 Subject: [PATCH] Move ui input to TS --- src/domain_abstract/ui/{Input.js => Input.ts} | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) rename src/domain_abstract/ui/{Input.js => Input.ts} (81%) diff --git a/src/domain_abstract/ui/Input.js b/src/domain_abstract/ui/Input.ts similarity index 81% rename from src/domain_abstract/ui/Input.js rename to src/domain_abstract/ui/Input.ts index 18d1fd0bf..c53cee395 100644 --- a/src/domain_abstract/ui/Input.js +++ b/src/domain_abstract/ui/Input.ts @@ -1,8 +1,15 @@ import Backbone from 'backbone'; +import { View } from '../../common'; +import EditorModel from '../../editor/model/Editor'; const $ = Backbone.$; -export default class Input extends Backbone.View { +export default class Input extends View { + ppfx!: string; + em!: EditorModel; + opts!: any; + inputEl?: any; + template() { return ``; } @@ -15,7 +22,7 @@ export default class Input extends Backbone.View { return `${this.ppfx}input-holder`; } - constructor(opts = {}) { + constructor(opts: any = {}) { super(opts); const ppfx = opts.ppfx || ''; this.opts = opts; @@ -35,7 +42,7 @@ export default class Input extends Backbone.View { * Set value to the input element * @param {string} value */ - setValue(value) { + setValue(value: string, opts?: any) { const model = this.model; let val = value || model.get('defaults'); const input = this.getInputEl(); @@ -45,21 +52,21 @@ export default class Input extends Backbone.View { /** * Updates the view when the model is changed * */ - handleModelChange(model, value, opts) { + handleModelChange(model: any, value: string, opts: any) { this.setValue(value, opts); } /** * Handled when the view is changed */ - handleChange(e) { + handleChange(e: Event) { e.stopPropagation(); const value = this.getInputEl().value; this.__onInputChange(value); this.elementUpdated(); } - __onInputChange(value) { + __onInputChange(value: string) { this.model.set({ value }, { fromInput: 1 }); } @@ -89,5 +96,6 @@ export default class Input extends Backbone.View { } Input.prototype.events = { + // @ts-ignore change: 'handleChange', };