mdui-ext
Version:
a extension for mdui !(not completed)
77 lines (76 loc) • 2.53 kB
JavaScript
import mdui from "mdui";
import { AttributeUtil } from "../utils/AttributeUtil";
class MduiSelectElement extends HTMLElement {
constructor() {
super();
this.classList.add("mdui-select");
document.addEventListener("DOMContentLoaded", () => {
this._select = new mdui.Select(this);
});
const timer = () => {
if (this._top != this.top) {
this._top = this.top;
if (this._select instanceof mdui.Select) {
if (this.top) {
console.warn("top", this.id);
this._select.options.position = "top";
this._select.handleUpdate();
}
else {
this._select.options.position = "auto";
this._select.handleUpdate();
}
}
}
};
const timer2 = () => {
if (this._bottom != this.bottom) {
this._bottom = this.bottom;
if (this._select instanceof mdui.Select) {
if (this.bottom) {
console.warn("bottom", this.id);
this._select.options.position = "bottom";
this._select.handleUpdate();
}
else {
this._select.options.position = "auto";
this._select.handleUpdate();
}
}
}
};
setInterval(timer, 50);
setInterval(timer2, 50);
}
get top() {
return AttributeUtil.isAttributeNotFalse(this, "top");
}
set top(isTop) {
this.setAttribute("top", String(isTop));
if (isTop) {
this._select.options.position = "top";
}
else {
this._select.options.position = "auto";
}
if (this._select instanceof mdui.Select) {
this._select.handleUpdate();
}
}
get bottom() {
return AttributeUtil.isAttributeNotFalse(this, "bottom");
}
set bottom(isBottom) {
this.setAttribute("bottom", String(isBottom));
if (isBottom) {
this._select.options.position = "bottom";
}
else {
this._select.options.position = "auto";
}
if (this._select instanceof mdui.Select) {
this._select.handleUpdate();
}
}
}
export { MduiSelectElement };