fantasy/ui/editors/form.js

37 lines
919 B
JavaScript
Raw Normal View History

import UI from "../ui.js";
class Form extends UI {
constructor(width, height) {
super(document.createElement("div"), width, height);
this.element.classList.add("form");
this._lines = [];
this._linesById = Object.create(null);
}
addLine(id, label, editor) {
2018-11-20 11:44:05 +00:00
let line = document.createElement("div");
let labelCell = document.createElement("div");
let editorCell = document.createElement("div");
labelCell.innerText = label;
editorCell.appendChild(editor.element);
line.appendChild(labelCell);
line.appendChild(editorCell);
let obj = {
id: id,
label: label,
editor: editor,
visible: true,
line: line
};
this._lines.push(obj);
this._linesById[id] = obj;
this.element.appendChild(line);
}
}
export default Form;