2
0
mirror of https://github.com/esiur/iui.git synced 2026-04-04 06:58:22 +00:00
Files
iui/src/Data/Layout.js
2022-02-13 19:34:09 +03:00

61 lines
1.6 KiB
JavaScript

import IUIElement from "../Core/IUIElement.js";
import Field from "./Field.js";
import { IUI } from "../Core/IUI.js";
export default IUI.module(
class Layout extends HTMLElement {
// IUIElement
constructor() {
super();
}
static get moduleName() {
return this.name.toLowerCase();
}
//create()
//{
// for (var i = 0; i < this.children.length; i++)
// if (this.children[i] instanceof Field) {
// this[this.children[i].name] = this.children[i];
// this.fields.push(this.children[i]);
// }
// this.style.display = "none";
//}
static getHTML(el, removeSelf = false) {
for (var i = 0; i < el.children.length; i++)
if (el.children[i] instanceof Layout) {
let layout = el.children[i];
let rt = layout.innerHTML;
if (removeSelf) el.removeChild(layout);
return rt;
}
return null;
}
static get(el, tag, removeSelf = false, collection = false) {
for (var i = 0; i < el.children.length; i++)
if (el.children[i] instanceof Layout) {
let layout = el.children[i];
let rt = collection ? {} : [];
for (var j = 0; j < layout.children.length; j++) {
if (layout.children[j] instanceof Field) {
let fd = layout.children[j].serialize(tag);
if (collection) rt[fd.name] = fd;
else rt.push(fd);
}
}
if (removeSelf) layout.parentElement.removeChild(layout);
return rt;
}
return null;
}
}
);