enhance the core API and default application

This commit is contained in:
Xuan Sang LE
2020-06-05 17:46:04 +02:00
parent fb462fe31b
commit f84da77825
15 changed files with 55 additions and 31 deletions

View File

@ -943,10 +943,13 @@ namespace OS {
<afx-vbox>
<afx-file-view data-id = "fileview" view="tree" status = "false"></afx-file-view>
<input data-height = '26' type = "text" data-id = "filename" style="margin-left:5px; margin-right:5px;display:none;" />
<div data-height = '30' style=' text-align:right;padding:3px;'>
<afx-button data-id = "bt-ok" text = "__(Ok)"></afx-button>
<afx-button data-id = "bt-cancel" text = "__(Cancel)"></afx-button>
</div>
<afx-hbox data-height = '30'>
<div style=' text-align:right;'>
<afx-button data-id = "bt-ok" text = "__(Ok)"></afx-button>
<afx-button data-id = "bt-cancel" text = "__(Cancel)"></afx-button>
</div>
<div data-width="5"></div>
</afx-hbox>
</afx-vbox>
</afx-hbox>
</afx-app-window>\

View File

@ -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<HTMLElement> {
if (this.scheme) {
return $(sel, this.scheme)[0];
return $(sel, this.scheme);
}
}
}

View File

@ -49,7 +49,7 @@ namespace OS {
* @memberof DB
*/
save(d: any): Promise<API.RequestResult> {
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,

View File

@ -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()
);

View File

@ -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()

View File

@ -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 {}

View File

@ -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();
}

View File

@ -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] === "%") {

View File

@ -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");
}
/**

View File

@ -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;
}
}
}
}