update v0.0.2 twa sys
This commit is contained in:
@ -44,12 +44,16 @@
|
||||
}).bind(this);
|
||||
break;
|
||||
case "Slide":
|
||||
var slideC = document.createElement("div");
|
||||
slideC.classList.add("slideContent");
|
||||
while (this.params.parent.childNodes.length > 0) {
|
||||
slideC.appendChild(this.params.parent.childNodes[0]);
|
||||
var slideC = this.params.parent.querySelector(".slideContent");
|
||||
if (slideC == null) {
|
||||
slideC = document.createElement("div");
|
||||
slideC.classList.add("slideContent");
|
||||
while (this.params.parent.childNodes.length > 0) {
|
||||
slideC.appendChild(this.params.parent.childNodes[0]);
|
||||
}
|
||||
this.params.parent.appendChild(slideC);
|
||||
}
|
||||
this.params.parent.appendChild(slideC);
|
||||
|
||||
|
||||
slideC.querySelectorAll(".tabcontent").forEach((el) => {
|
||||
let style = this.params.parent.currentStyle || window.getComputedStyle(this.params.parent);
|
||||
|
||||
@ -51,7 +51,6 @@ export default class Dropdown extends window.AObject {
|
||||
if (this.isLock) {
|
||||
return;
|
||||
}
|
||||
console.log("Asdasd");
|
||||
var t1 = e.currentTarget;
|
||||
var p = t1.closest('[data-dropdown]');
|
||||
var p1 = e.target.closest(".noopen");
|
||||
|
||||
@ -10,10 +10,10 @@ export default class AMenu extends window.AObject {
|
||||
this.navD = document.querySelector(nav);
|
||||
this.transition = new ATransitionEffect();
|
||||
this.overlay = new AOverlay(document.body);
|
||||
|
||||
|
||||
this.isMDiffD = isMDiffD;
|
||||
this.changeActive();
|
||||
|
||||
|
||||
if (btnMs != null) {
|
||||
if (!(Array.isArray(btnMs) || btnMs instanceof NodeList || btnMs instanceof HTMLCollection)) {
|
||||
const tmp = [];
|
||||
@ -21,14 +21,14 @@ export default class AMenu extends window.AObject {
|
||||
btnMs = tmp;
|
||||
}
|
||||
btnMs.forEach((el => {
|
||||
|
||||
|
||||
var f = function (e) {
|
||||
this.mobileMenu.call(this, e, el);
|
||||
}.bind(this);
|
||||
el.addEventListener(this.eventName, f, false);
|
||||
this.addSystemEvent(this.eventName, el, f, "icomenu");
|
||||
this.listIco.push(el);
|
||||
|
||||
|
||||
}).bind(this));
|
||||
this.overlay.createOverlay();
|
||||
this.overlay.setIndex(2000);
|
||||
@ -54,7 +54,7 @@ export default class AMenu extends window.AObject {
|
||||
this.initNav(this.navM, "M");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
initNav(ele, type = "D") {
|
||||
let arr = ele.querySelectorAll(".nav-i.has-sub .nav-link, .navmain > .nav-i:not(.has-sub) a");
|
||||
Array.from(arr).forEach(el => {
|
||||
@ -81,10 +81,10 @@ export default class AMenu extends window.AObject {
|
||||
}
|
||||
updateIdPage() {
|
||||
this.idPage = document.head.querySelector("meta[name=idPage]").content;
|
||||
|
||||
|
||||
this.navActiveD = this.navD.querySelector("a[nav-id='" + this.idPage + "']");
|
||||
if (this.isMDiffD) {
|
||||
this.navActiveM = this.navM.querySelector("a[nav-id='" + this.idPage + "']");
|
||||
this.navActiveM = this.navM.querySelector("a[nav-id='" + this.idPage + "']");
|
||||
}
|
||||
window.removeStopCollapsed();
|
||||
}
|
||||
@ -140,7 +140,7 @@ export default class AMenu extends window.AObject {
|
||||
}
|
||||
}).bind(this));
|
||||
}).bind(this), 100);
|
||||
|
||||
|
||||
}
|
||||
closeExpandMenu() {
|
||||
Array.from(this.navM.querySelectorAll(".nav-i.has-sub")).forEach(el => {
|
||||
|
||||
@ -52,7 +52,9 @@ export default class AModal extends window.AObject {
|
||||
showModal() {
|
||||
this.overlay.showOverlay();
|
||||
}
|
||||
|
||||
removeModal() {
|
||||
this.overlay.removeOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
class AModalOK {
|
||||
|
||||
@ -3,8 +3,8 @@ export default class AMultiTag extends window.AObject {
|
||||
super();
|
||||
this.parent = ele;
|
||||
this.cItems = ele.querySelector(".input-content");
|
||||
this.itemEles = [];
|
||||
this.itemDatas = [];
|
||||
this.itemEles = new Map();
|
||||
this.itemDatas = new Map();
|
||||
this.btnAdd = ele.querySelector(".btn-Add");
|
||||
this.btnAdd.addEventListener("click", ((e) => {
|
||||
this.parent.classList.add("active");
|
||||
@ -16,6 +16,11 @@ export default class AMultiTag extends window.AObject {
|
||||
}
|
||||
initGlobalVar() {
|
||||
var f = function (ev) {
|
||||
const close = ev.target.closest(".con-ico");
|
||||
if (close) {
|
||||
const t = close.closest(".item[data-id]");
|
||||
if (t) this.removeItem(1 * t.getAttribute("data-id"));
|
||||
}
|
||||
if (ev.target.closest(".amultitag") || ev.target.closest(".c-aoverlay")) {
|
||||
return;
|
||||
} else {
|
||||
@ -26,22 +31,32 @@ export default class AMultiTag extends window.AObject {
|
||||
window.AMultiTag = true;
|
||||
}
|
||||
addItem(id, name, obj, action = null) {
|
||||
var ele = this.addItem(id, name, action);
|
||||
this.itemEles.push(ele);
|
||||
this.itemDatas.push(obj);
|
||||
var ele = this.createItem(id, name, action);
|
||||
this.itemEles.set(id, ele);
|
||||
this.itemDatas.set(id, obj);
|
||||
this.cItems.appendChild(ele);
|
||||
}
|
||||
removeItem(id) {
|
||||
const t = this.itemEles.get(id);
|
||||
this.itemDatas.delete(id);
|
||||
this.itemEles.delete(id);
|
||||
t.remove();
|
||||
}
|
||||
createItem(id, name, action) {
|
||||
var p = document.createElement("div");
|
||||
p.setAttribute("data-id", id);
|
||||
p.classList.add("item");
|
||||
p.classList.add("item", "d-f", "a-i-center");
|
||||
var label = document.createElement("span");
|
||||
label.innerHTML = name;
|
||||
label.classList.add("name");
|
||||
if (action != null) {
|
||||
p.appendChild(action);
|
||||
}
|
||||
let close = document.createElement("div");
|
||||
close.classList.add("con-ico", "d-f", "a-i-center", "j-c-center");
|
||||
p.appendChild(label);
|
||||
close.innerHTML = `<span class="atg a-1x atg-x"></span>`;
|
||||
p.appendChild(close);
|
||||
return p;
|
||||
}
|
||||
}
|
||||
@ -182,6 +182,7 @@ class ASelectEle extends window.AObject {
|
||||
if (this.selectedEleItem != null) this.selectedEleItem.classList.remove("active");
|
||||
this.selectedEleItem = this.listItems[idx].element;
|
||||
this.selectedItem = this.listItems[idx];
|
||||
|
||||
this.removeAllChildNodes(this.cSelectedItem);
|
||||
this.cloneNodes(this.selectedEleItem, this.cSelectedItem);
|
||||
this.setElement(this.selectedEleItem);
|
||||
@ -398,7 +399,6 @@ class ASelectEle extends window.AObject {
|
||||
}
|
||||
if (tmp != null && tmp.classList.contains("a-option")) {
|
||||
this.updateIndex(tmp.getAttribute("index"));
|
||||
console.log(tmp.offsetTop);
|
||||
this.scroll.scrollIntoView(tmp, {
|
||||
alignToTop: false,
|
||||
offsetBottom: 0,
|
||||
|
||||
69
TWASys-App/wwwroot/js/libs/js-ASlideDown.js
Normal file
69
TWASys-App/wwwroot/js/libs/js-ASlideDown.js
Normal file
@ -0,0 +1,69 @@
|
||||
import ATransitionEffect from '/js/libs/js-ATransitionEffect.js'
|
||||
|
||||
export default class ASlideDown extends window.AObject {
|
||||
constructor(el) {
|
||||
super();
|
||||
this._eleM = [];
|
||||
if (el instanceof NodeList) {
|
||||
Array.from(el).forEach((e) => {
|
||||
this._eleM.push(new ASlideDownEle(e))
|
||||
});
|
||||
} else {
|
||||
this._eleM.push(new ASlideDownEle(el));
|
||||
}
|
||||
}
|
||||
get(i) {
|
||||
return this._eleM[i];
|
||||
}
|
||||
}
|
||||
|
||||
class ASlideDownEle extends window.AObject {
|
||||
constructor(ele) {
|
||||
super();
|
||||
this.transition = new ATransitionEffect();
|
||||
this._ele = ele;
|
||||
this._pCon = ele.closest('[data-dropdown]');
|
||||
this._subI = this._pCon.querySelector(".sub-item");
|
||||
var f = function (ev) {
|
||||
if (window.isValidPointerClick(ev)) return;
|
||||
this.onClick.call(this, ev);
|
||||
}.bind(this);
|
||||
this.addSystemEvent(this.eventName, this._ele, f);
|
||||
}
|
||||
enable() {
|
||||
this._ele.classList.remove("disabled");
|
||||
}
|
||||
disable() {
|
||||
this._ele.classList.add("disabled");
|
||||
}
|
||||
enable_Open() {
|
||||
this.enable();
|
||||
this.open();
|
||||
}
|
||||
disable_Close() {
|
||||
this.disable();
|
||||
this.close();
|
||||
}
|
||||
open() {
|
||||
if (this._ele.classList.contains("disabled")) {
|
||||
return;
|
||||
}
|
||||
this._pCon.classList.add("active");
|
||||
this.transition.expandEffect(this._subI, function () {
|
||||
this.trigger("opened");
|
||||
}.bind(this));
|
||||
}
|
||||
close() {
|
||||
this._pCon.classList.remove("active");
|
||||
this.transition.collapsedEffect(this._subI, function () {
|
||||
this.trigger("closed");
|
||||
}.bind(this));
|
||||
}
|
||||
onClick(e) {
|
||||
if (this._pCon.classList.contains("active")) {
|
||||
this.close();
|
||||
} else {
|
||||
this.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -33,7 +33,14 @@ export default class AWizard extends ATab {
|
||||
Cancel
|
||||
</button>
|
||||
</div>`;
|
||||
|
||||
|
||||
const ro = new ResizeObserver((entries => {
|
||||
for (const e of entries) {
|
||||
const { width, height } = e.contentRect;
|
||||
this.aAnimation.setType(this.typeAnimation, { "parent": this.tabContents });
|
||||
}
|
||||
}).bind(this));
|
||||
ro.observe(this.tabContents);
|
||||
}
|
||||
showPage(i) {
|
||||
this.cPage = i;
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
this.pElement = e;
|
||||
this.Headers = [];
|
||||
this.lSysRows = [];
|
||||
this.labelID = "";
|
||||
this.InitStructure();
|
||||
this.InitCss();
|
||||
this.SetIdCheckBox();
|
||||
@ -18,7 +19,8 @@
|
||||
}
|
||||
}
|
||||
SetScrollBarY(height) {
|
||||
this.absContainerRows.style.height = height + "px";
|
||||
this.absContainerRows.style.height = "auto";
|
||||
this.absContainerRows.style.maxHeight = height + "px";
|
||||
}
|
||||
AddHeader(name, width, minWidth, id = "", rowTemp = null) {
|
||||
var d = document.createElement("th");
|
||||
@ -184,10 +186,15 @@
|
||||
this.data.forEach((e, i) => {
|
||||
var r = document.createElement("tr");
|
||||
r.setAttribute("data-id", i);
|
||||
this.Headers.forEach((o) => {
|
||||
this.Headers.forEach((o, j) => {
|
||||
|
||||
var td = document.createElement("td");
|
||||
if (o.rowTemp != null) {
|
||||
td.appendChild(o.rowTemp(i, e));
|
||||
const rT = o.rowTemp(i, e);
|
||||
if (this.isCheckBox && j < 1) {
|
||||
rT.setAttribute("id", (this.labelID.length >0)?e[this.labelID]:"");
|
||||
}
|
||||
td.appendChild(rT);
|
||||
} else {
|
||||
td.innerHTML = e[o.id];
|
||||
}
|
||||
|
||||
@ -104,14 +104,14 @@ window.getOS = function () {
|
||||
return os;
|
||||
}
|
||||
|
||||
window.GetAbsoluteURL = function(relativeURL) {
|
||||
window.GetAbsoluteURL = function (relativeURL) {
|
||||
if (relativeURL.startsWith(window.location.origin)) {
|
||||
return relativeURL;
|
||||
}
|
||||
return window.location.origin + relativeURL;
|
||||
}
|
||||
|
||||
window.getPathFromUrl = function(url) {
|
||||
window.getPathFromUrl = function (url) {
|
||||
const parsed = new URL(url);
|
||||
return parsed.pathname + parsed.search + parsed.hash;
|
||||
}
|
||||
@ -377,9 +377,9 @@ window.AObject = class {
|
||||
const eventMap = this.systemEvents.get(element);
|
||||
if (eventMap) {
|
||||
const data = eventMap.get(eventName);
|
||||
|
||||
|
||||
if (data && typeof data.callback === 'function') {
|
||||
element.removeEventListener(eventName , data.callback, false);
|
||||
element.removeEventListener(eventName, data.callback, false);
|
||||
eventMap.delete(eventName);
|
||||
// Nếu element không còn event nào, xóa khỏi systemEvents
|
||||
if (eventMap.size === 0) {
|
||||
@ -387,7 +387,7 @@ window.AObject = class {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
this.parentEventMap.delete(parent);
|
||||
}
|
||||
@ -406,7 +406,7 @@ window.AObject = class {
|
||||
}
|
||||
addCustomEvent(id, element, groups = null) {
|
||||
if (!this.customEvents.has(id)) {
|
||||
this.customEvents.set(id, { "ele":element, "groups":groups });
|
||||
this.customEvents.set(id, { "ele": element, "groups": groups });
|
||||
}
|
||||
if (groups) {
|
||||
if (!this.parentEventMap.has("Custom" + parent)) {
|
||||
@ -429,6 +429,7 @@ window.AObject = class {
|
||||
}
|
||||
this.parentEventMap.get(parent).add({ element, eventName });
|
||||
}
|
||||
|
||||
}
|
||||
removeAllChildNodes(parent) {
|
||||
while (parent.firstChild) {
|
||||
@ -541,12 +542,11 @@ class AApp extends window.AObject {
|
||||
this.metaPage = document.head.querySelector("meta[name=idPage]");
|
||||
this.pageName = this.metaPage.getAttribute("pageName");
|
||||
this.lName = this.metaPage.getAttribute("layName");
|
||||
console.log(this.lName);
|
||||
var tmp = document.querySelector(container);
|
||||
this.mainApp = tmp.querySelector("[main-content]") ? tmp.querySelector("[main-content]") : tmp;
|
||||
var f = function (ev) {
|
||||
if (ev.state) {
|
||||
this.cachePage.get(ev.state.url, ((result) => {
|
||||
this.cachePage.get(ev.state.url, ((result) => {
|
||||
if (result == null) {
|
||||
|
||||
} else {
|
||||
@ -655,7 +655,7 @@ class AApp extends window.AObject {
|
||||
this.addSystemEvent("click", el, f1, groups)
|
||||
const f2 = (function (ev) {
|
||||
if (window.isValidPointerClick(ev)) return;
|
||||
|
||||
|
||||
this.initNavApp(ev.currentTarget.getAttribute("href"), ev.currentTarget.hasAttribute("isflexpage"));
|
||||
}).bind(this);
|
||||
this.addSystemEvent(this.eventName, el, f2, groups);
|
||||
@ -689,8 +689,7 @@ class AApp extends window.AObject {
|
||||
doc: doc,
|
||||
dynamicF: a.dynamicF
|
||||
};
|
||||
|
||||
this.setContentPage(obj, url);
|
||||
this.setContentPage(obj, url);
|
||||
} else {
|
||||
this.getPage(url, result)
|
||||
}
|
||||
@ -699,17 +698,6 @@ class AApp extends window.AObject {
|
||||
this.getPage(url);
|
||||
}
|
||||
}).bind(this));
|
||||
//if (flex) {
|
||||
|
||||
//} else {
|
||||
// this.cachePage.get(url, ((result) => {
|
||||
// if (result) {
|
||||
// // Set content page từ cache
|
||||
// } else {
|
||||
// this.getPage(url); // Load mới nếu chưa có trong cache
|
||||
// }
|
||||
// }).bind(this));
|
||||
//}
|
||||
}
|
||||
loadContentPage(content) {
|
||||
const tpl = document.createElement('template');
|
||||
@ -723,12 +711,10 @@ class AApp extends window.AObject {
|
||||
document.title = page.title + " - " + this.pageName;
|
||||
var meta = document.head.querySelector("meta[name=idPage]");
|
||||
document.body.setAttribute("page", page.idPage);
|
||||
|
||||
meta.content = page.idPage;
|
||||
this.lName = page.lName;
|
||||
meta.setAttribute("layName", page.lName);
|
||||
meta.setAttribute("layName", page.lName);
|
||||
this.loadContentPage(page.html);
|
||||
window.history.pushState({"url":url}, page.title, url);
|
||||
window.history.pushState({ "url": url }, page.title, url);
|
||||
}
|
||||
setContentPage(page, url) {
|
||||
this.contentPage(page, url);
|
||||
@ -778,7 +764,6 @@ class AApp extends window.AObject {
|
||||
loadedPage() {
|
||||
this.metaPage = document.head.querySelector("meta[name=idPage]");
|
||||
if (this.metaPage != null && this.isLoadedLayout) {
|
||||
console.log(window.location.href);
|
||||
this.cachePage.searchFlexPage(window.getPathFromUrl(window.location.href), ((tmp) => {
|
||||
tmp = tmp.layout.info;
|
||||
if (tmp != null && tmp.dynamicF != null) {
|
||||
@ -790,7 +775,7 @@ class AApp extends window.AObject {
|
||||
this.initNavs(this.metaPage.content);
|
||||
this.trigger("pageLoaded", null);
|
||||
}).bind(this));
|
||||
|
||||
|
||||
} else {
|
||||
window.requestTimeout(this.loadedPage.bind(this), 10, window.registerCancel);
|
||||
}
|
||||
@ -803,9 +788,9 @@ class AApp extends window.AObject {
|
||||
console.log("connect new Layout");
|
||||
this.loadLayout(); // Load mới nếu chưa có trong cache
|
||||
}
|
||||
|
||||
|
||||
}).bind(this), "layout");
|
||||
|
||||
|
||||
}
|
||||
loadLayout() {
|
||||
(function () {
|
||||
@ -825,10 +810,9 @@ class AApp extends window.AObject {
|
||||
}).bind(this)();
|
||||
}
|
||||
loadedLayout() {
|
||||
console.log(this.lName);
|
||||
if (this.lName !== "None") {
|
||||
const l = window.ALayout.get(this.lName);
|
||||
if (!l.isLoaded) {
|
||||
if (!l.isLoaded) {
|
||||
l.renderMenu();
|
||||
this.isLoadedLayout = true;
|
||||
this.trigger("layoutLoaded", null);
|
||||
@ -928,7 +912,7 @@ class CacheManager {
|
||||
|
||||
// Lấy thông tin trang hoặc layout
|
||||
|
||||
|
||||
|
||||
// Lấy dữ liệu từ cache (localStorage hoặc IndexedDB nếu cần)
|
||||
get(id, callback, type = "cahce") {
|
||||
this._onReady(() => {
|
||||
@ -986,7 +970,7 @@ class CacheManager {
|
||||
this.countFP++;
|
||||
}
|
||||
this.storage.set("treePage", this.flexPages.toJSON(), function () { });
|
||||
} else {
|
||||
} else {
|
||||
const layout = {
|
||||
Content: obj.Content,
|
||||
Scripts: obj.Scripts
|
||||
@ -1054,7 +1038,7 @@ class CacheStorage {
|
||||
del.onblocked = () => {
|
||||
console.warn("deleteDatabase blocked (tab khác đang giữ kết nối)");
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
_flushQueue() {
|
||||
while (this.queue.length) {
|
||||
@ -1104,7 +1088,7 @@ class CacheStorage {
|
||||
}
|
||||
});
|
||||
}
|
||||
set(key, data, callback = () => { }, type="cache") {
|
||||
set(key, data, callback = () => { }, type = "cache") {
|
||||
this._onReady(() => {
|
||||
if (this.db) {
|
||||
let tx, store, req;
|
||||
@ -1117,7 +1101,7 @@ class CacheStorage {
|
||||
store = tx.objectStore("cache");
|
||||
store.put({ key: this._key(key), value: data, ts: Date.now() });
|
||||
}
|
||||
|
||||
|
||||
tx.oncomplete = () => callback(null);
|
||||
tx.onerror = (e) => callback(e);
|
||||
} else {
|
||||
@ -1126,7 +1110,7 @@ class CacheStorage {
|
||||
localStorage.setItem(this._key(key), JSON.stringify({ data, ts: Date.now() }));
|
||||
callback(null);
|
||||
} catch (e) {
|
||||
|
||||
|
||||
callback(e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user