From f84da778258fef1e14ceb7c7b28592b7a66558c5 Mon Sep 17 00:00:00 2001 From: Xuan Sang LE Date: Fri, 5 Jun 2020 17:46:04 +0200 Subject: [PATCH] enhance the core API and default application --- src/core/BaseDialog.ts | 11 +++++++---- src/core/BaseModel.ts | 7 ++++--- src/core/db.ts | 2 +- src/core/gui.ts | 12 ++++++------ src/core/tags/NSpinnerTag.ts | 7 +++++-- src/core/tags/SwitchTag.ts | 1 + src/core/tags/TabContainerTag.ts | 2 +- src/core/tags/TileLayoutTags.ts | 5 ++++- src/core/tags/TreeViewTag.ts | 4 +++- src/core/tags/tag.ts | 18 +++++++++++++++++- src/packages/Files/scheme.html | 3 ++- src/packages/Syslog/Syslog.ts | 5 ++--- src/themes/antos_dark/afx-grid-view.css | 2 +- src/themes/antos_dark/afx-tree-view.css | 4 +--- src/themes/antos_light/afx-tree-view.css | 3 --- 15 files changed, 55 insertions(+), 31 deletions(-) diff --git a/src/core/BaseDialog.ts b/src/core/BaseDialog.ts index 028cc78..668cf98 100644 --- a/src/core/BaseDialog.ts +++ b/src/core/BaseDialog.ts @@ -943,10 +943,13 @@ namespace OS { -
- - -
+ +
+ + +
+
+
\ diff --git a/src/core/BaseModel.ts b/src/core/BaseModel.ts index 5c1db19..1d4ae2f 100644 --- a/src/core/BaseModel.ts +++ b/src/core/BaseModel.ts @@ -319,7 +319,8 @@ namespace OS { * @memberof BaseModel */ trigger(e: string, d?: any): void { - return this.observable.trigger(e, d); + if(!this.observable) return; + this.observable.trigger(e, d); } @@ -509,9 +510,9 @@ namespace OS { * @returns {HTMLElement} * @memberof BaseModel */ - protected select(sel: string): HTMLElement { + protected select(sel: string): JQuery { if (this.scheme) { - return $(sel, this.scheme)[0]; + return $(sel, this.scheme); } } } diff --git a/src/core/db.ts b/src/core/db.ts index 5c48c55..be61761 100644 --- a/src/core/db.ts +++ b/src/core/db.ts @@ -49,7 +49,7 @@ namespace OS { * @memberof DB */ save(d: any): Promise { - return new Promise(async function (resolve, reject) { + return new Promise(async (resolve, reject) => { try { const r = await Ant.OS.API.handle.dbquery("save", { table: this.table, diff --git a/src/core/gui.ts b/src/core/gui.ts index 6d76fd4..8ccd7f0 100644 --- a/src/core/gui.ts +++ b/src/core/gui.ts @@ -314,10 +314,10 @@ namespace OS { */ export function unloadApp(app: string): void { PM.killAll(app, true); - if (app[app] && app[app].style) { - $(app[app].style).remove(); + if (application[app] && application[app].style) { + $(application[app].style).remove(); } - delete app[app]; + delete application[app]; } /** @@ -333,7 +333,6 @@ namespace OS { path = setting.system.packages[app].path; } const js = path + "/main.js"; - try { const d = await js.asFileHandle().read("script"); try { @@ -613,9 +612,11 @@ namespace OS { function bindContextMenu(event: JQuery.MouseEventBase): void { var handle = function (e: HTMLElement) { if (e.contextmenuHandle) { + const m = $("#contextmenu")[0] as tag.MenuTag; + m.onmenuselect = () => {} return e.contextmenuHandle( event, - $("#contextmenu")[0] as tag.MenuTag + m ); } else { const p = $(e).parent().get(0); @@ -995,7 +996,6 @@ namespace OS { loadTheme(setting.appearance.theme, true); wallpaper(undefined); OS.announcer.observable.one("syspanelloaded", async function () { - // TODO load packages list then build system menu OS.announcer.observable.on("systemlocalechange", (name) => $("#syspanel")[0].update() ); diff --git a/src/core/tags/NSpinnerTag.ts b/src/core/tags/NSpinnerTag.ts index 356c5c1..dca621a 100644 --- a/src/core/tags/NSpinnerTag.ts +++ b/src/core/tags/NSpinnerTag.ts @@ -34,7 +34,10 @@ namespace OS { * @protected * @memberof NSpinnerTag */ - protected init(): void {} + protected init(): void { + this._value = 0; + this.step = 1; + } /** * @@ -67,7 +70,7 @@ namespace OS { }); $(this.refs.decr).click((e) => { - return (this.value = this.value - this.step); + this.value = this.value - this.step; }); // @observable.on "calibrate", () -> @calibrate() diff --git a/src/core/tags/SwitchTag.ts b/src/core/tags/SwitchTag.ts index a534639..78dece6 100644 --- a/src/core/tags/SwitchTag.ts +++ b/src/core/tags/SwitchTag.ts @@ -66,6 +66,7 @@ namespace OS { protected init(): void { this.swon = false; this.enable = true; + this._onchange = this._onchanging = (e) => {}; } protected calibrate(): void {} protected reload(d?: any): void {} diff --git a/src/core/tags/TabContainerTag.ts b/src/core/tags/TabContainerTag.ts index 32e2760..bda7c6d 100644 --- a/src/core/tags/TabContainerTag.ts +++ b/src/core/tags/TabContainerTag.ts @@ -128,7 +128,7 @@ namespace OS { * * @memberof TabContainerTag */ - set tabbarheigh(v: number) { + set tabbarheight(v: number) { $(this.refs.bar).attr("data-height", `${v}`); (this.refs.wrapper as TileLayoutTag).calibrate(); } diff --git a/src/core/tags/TileLayoutTags.ts b/src/core/tags/TileLayoutTags.ts index e842d60..45c5e3d 100644 --- a/src/core/tags/TileLayoutTags.ts +++ b/src/core/tags/TileLayoutTags.ts @@ -44,7 +44,8 @@ namespace OS { $(this).css("display", "block"); $(this.refs.yield) .css("display", "flex") - .css("width", "100%"); + .css("width", "100%") + .css("height", "100%"); this.observable.on("resize", (e) => this.calibrate()); return this.calibrate(); } @@ -67,6 +68,7 @@ namespace OS { $(this.refs.yield) .children() .each(function (e) { + $(this).css("height", "100%"); let attv = $(this).attr("data-width"); let dw = 0; if (attv && attv !== "grow") { @@ -108,6 +110,7 @@ namespace OS { .children() .each(function (e) { let dh = 0; + $(this).css("width", "100%"); let attv = $(this).attr("data-height"); if (attv && attv !== "grow") { if (attv[attv.length - 1] === "%") { diff --git a/src/core/tags/TreeViewTag.ts b/src/core/tags/TreeViewTag.ts index a82cb9e..8f0c866 100644 --- a/src/core/tags/TreeViewTag.ts +++ b/src/core/tags/TreeViewTag.ts @@ -168,8 +168,10 @@ namespace OS { $(this.refs.toggle).addClass( "afx-tree-view-folder-open" ); + } else { + $(this.refs.toggle).addClass("afx-tree-view-folder-close"); } - $(this.refs.toggle).addClass("afx-tree-view-folder-close"); + } /** diff --git a/src/core/tags/tag.ts b/src/core/tags/tag.ts index 1a21d00..1926b69 100644 --- a/src/core/tags/tag.ts +++ b/src/core/tags/tag.ts @@ -241,7 +241,23 @@ namespace OS { name: string, cls: { new (): T } ): void { - customElements.define(name, cls); + try { + customElements.define(name, cls); + } catch (error) { + const proto = customElements.get(name); + if(cls) + { + const props = Object.getOwnPropertyNames(cls.prototype); + // redefine the class + for(let prop of props) + { + proto.prototype[prop] = cls.prototype[prop]; + } + return; + } + throw error; + + } } } } diff --git a/src/packages/Files/scheme.html b/src/packages/Files/scheme.html index 737f121..1abc994 100644 --- a/src/packages/Files/scheme.html +++ b/src/packages/Files/scheme.html @@ -1,6 +1,6 @@ - +
@@ -8,6 +8,7 @@
+
diff --git a/src/packages/Syslog/Syslog.ts b/src/packages/Syslog/Syslog.ts index 3fc1310..2468905 100644 --- a/src/packages/Syslog/Syslog.ts +++ b/src/packages/Syslog/Syslog.ts @@ -179,15 +179,14 @@ detail: }; this.loglist.onitemclose = (e) => { - let el; + let el: TAG.ListViewItemTag; if (e && e.data) { el = e.data.item; } if (!el) { return true; } - const data = el.get("data"); - console.log(data); + const data = el.data; if (!data.selected) { return true; } diff --git a/src/themes/antos_dark/afx-grid-view.css b/src/themes/antos_dark/afx-grid-view.css index 90e0cd7..74db391 100644 --- a/src/themes/antos_dark/afx-grid-view.css +++ b/src/themes/antos_dark/afx-grid-view.css @@ -10,7 +10,7 @@ afx-grid-view afx-grid-row.afx-grid-row-selected afx-grid-cell } afx-grid-view afx-grid-row.afx-grid-row-selected afx-grid-cell.afx-grid-cell-selected { - font-weight: bold; + font-weight: normal; } diff --git a/src/themes/antos_dark/afx-tree-view.css b/src/themes/antos_dark/afx-tree-view.css index 7a869f2..72ca4af 100644 --- a/src/themes/antos_dark/afx-tree-view.css +++ b/src/themes/antos_dark/afx-tree-view.css @@ -1,6 +1,4 @@ -afx-tree-view{ - padding:3px; -} + afx-tree-view div{ padding:3px; } diff --git a/src/themes/antos_light/afx-tree-view.css b/src/themes/antos_light/afx-tree-view.css index 8f0ff09..50a6f7b 100644 --- a/src/themes/antos_light/afx-tree-view.css +++ b/src/themes/antos_light/afx-tree-view.css @@ -1,6 +1,3 @@ -afx-tree-view{ - padding:3px; -} afx-tree-view div{ padding:3px; }