mirror of
https://github.com/esiur/iui.git
synced 2025-12-17 03:50:24 +00:00
initial commit
This commit is contained in:
62
src/Data/Field.js
Normal file
62
src/Data/Field.js
Normal file
@@ -0,0 +1,62 @@
|
||||
import IUIElement from "../Core/IUIElement.js";
|
||||
import { IUI } from "../Core/IUI.js";
|
||||
|
||||
|
||||
export default IUI.module(class Field extends HTMLElement
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
static get moduleName(){
|
||||
return this.name.toLowerCase();
|
||||
}
|
||||
|
||||
create()
|
||||
{
|
||||
// if (this.formatter === undefined) {
|
||||
// // load script
|
||||
// for (var i = 0; i < this.children.length; i++)
|
||||
// if (this.children[i] instanceof HTMLScriptElement) {
|
||||
// //this.formatter = new Function this.children[i].
|
||||
// }
|
||||
// }
|
||||
|
||||
//this.style.display = "none";
|
||||
}
|
||||
|
||||
get name() {
|
||||
return this.getAttribute("name");
|
||||
}
|
||||
|
||||
set name(value) {
|
||||
this.setAttribute("name", value);
|
||||
}
|
||||
|
||||
serialize(tag) {
|
||||
|
||||
let template = document.createElement("template");
|
||||
let node = document.createElement(tag ?? "div");
|
||||
let width = null, name = null, type = null;
|
||||
|
||||
// copy attributes
|
||||
for (var i = 0; i < this.attributes.length; i++) {
|
||||
let attr = this.attributes[i];
|
||||
if (attr.name == "width")
|
||||
width = attr.value;
|
||||
else if (attr.name == "name")
|
||||
name = attr.value;
|
||||
else if (attr.name == "type")
|
||||
type = attr.value;
|
||||
else
|
||||
node.setAttribute(attr.name, attr.value);
|
||||
}
|
||||
|
||||
// copy html
|
||||
|
||||
node.innerHTML = this.innerHTML;
|
||||
|
||||
return { node, width, name, type };
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user