From 9f28289bb6099b7eb4408c92de831f574200b484 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 29 Jun 2024 21:10:40 +0800 Subject: [PATCH] bugfix --- bricks/input.js | 81 ++++++++++++++++++--------------------- bricks/markdown_viewer.js | 2 +- 2 files changed, 39 insertions(+), 44 deletions(-) diff --git a/bricks/input.js b/bricks/input.js index 5c04d6a..cae59bf 100755 --- a/bricks/input.js +++ b/bricks/input.js @@ -52,9 +52,9 @@ bricks.UiAudioText = class extends bricks.UiType { "upload_url" } */ - static uitype = 'audiotext'; constructor(opts){ super(opts); + this.uitype = 'audiotext'; this.recorder = new bricks.AudioRecorder({ icon_rate:2, upload_url:opts.upload_url @@ -83,15 +83,14 @@ bricks.UiAudioText = class extends bricks.UiType { } bricks.UiHide = class extends bricks.UiType { - static uitype = 'hide'; constructor(opts){ super(opts); + this.uitype = 'hide'; this.set_style('display', 'none'); } } bricks.UiStr =class extends bricks.UiType { - static uitype='str'; /* { name: @@ -108,6 +107,7 @@ bricks.UiStr =class extends bricks.UiType { */ constructor(opts){ super(opts); + this.uitype='str'; this.rate = this.opts.rate || 1; this.dynsize = this.opts.dynsize || true; this.cfontsize = this.opts.cfontsize || 1; @@ -204,7 +204,6 @@ bricks.UiStr =class extends bricks.UiType { } bricks.UiPassword =class extends bricks.UiStr { - static uitype='password'; /* { name: @@ -221,11 +220,11 @@ bricks.UiPassword =class extends bricks.UiStr { constructor(opts){ opts.dynsize = opts.dynsize || true; super(opts); + this.uitype='password'; this.dom_element.type = 'password'; } } bricks.UiInt =class extends bricks.UiStr { - static uitype='int'; /* { length: @@ -233,6 +232,7 @@ bricks.UiInt =class extends bricks.UiStr { */ constructor(options){ super(options); + this.uitype='int'; this.dom_element.style.textAlign = 'right'; this.dom_element.type = 'number'; this.pattern = '\\d*'; @@ -249,7 +249,6 @@ bricks.UiInt =class extends bricks.UiStr { } bricks.UiFloat =class extends bricks.UiInt { - static uitype='float'; /* { dec_len: @@ -257,6 +256,7 @@ bricks.UiFloat =class extends bricks.UiInt { */ constructor(options){ super(options); + this.uitype='float'; this.pattern = '\\d*\\.?\\d+'; var dec_len = this.opts.dec_len || 2; var step = 1; @@ -275,7 +275,6 @@ bricks.UiFloat =class extends bricks.UiInt { } } bricks.UiTel =class extends bricks.UiStr { - static uitype='tel'; /* { @@ -284,6 +283,7 @@ bricks.UiTel =class extends bricks.UiStr { */ constructor(opts){ super(opts); + this.uitype='tel'; this.dom_element.type = 'tel'; if (this.opts.pattern) this.dom_element.pattern = this.opts.pattern; @@ -292,13 +292,13 @@ bricks.UiTel =class extends bricks.UiStr { } bricks.UiEmail =class extends bricks.UiStr { - static uitype='email'; /* { } */ constructor(opts){ super(opts); + this.uitype='email'; this.dom_element.type = 'email'; if (this.opts.pattern) this.dom_element.pattern = this.opts.pattern; @@ -308,7 +308,6 @@ bricks.UiEmail =class extends bricks.UiStr { } bricks.UiFile =class extends bricks.UiStr { - static uitype='file'; /* { accept: @@ -318,6 +317,7 @@ bricks.UiFile =class extends bricks.UiStr { */ constructor(opts){ super(opts); + this.uitype='file'; this.dom_element.type = 'file'; if (this.opts.accept) this.dom_element.accept = this.opts.accept; @@ -340,10 +340,10 @@ bricks.UiFile =class extends bricks.UiStr { } bricks.UiImage =class extends bricks.VBox { - static uitype='image'; constructor(opts){ opts.name = opts.name || 'image'; super(options); + this.uitype='image'; this.bind('drop', this.dropHandle.bind(this)); this.input = document.createElement('input'); this.input.type = 'file'; @@ -388,9 +388,9 @@ bricks.UiImage =class extends bricks.VBox { } bricks.UiCheck =class extends bricks.UiType { - static uitype = 'check'; constructor(opts){ super(opts); + this.uitype = 'check'; bricks.extend(bricks.UiCheck.prototype, bricks.Layout.prototype); this.add_widget = bricks.Layout.prototype.add_widget.bind(this); this.dom_element.style.width = 'auto'; @@ -440,7 +440,6 @@ bricks.UiCheck =class extends bricks.UiType { } bricks.UiCheckBox =class extends bricks.UiType { - static uitype='checkbox'; /* { name: @@ -464,6 +463,7 @@ bricks.UiCheckBox =class extends bricks.UiType { */ constructor(opts){ super(opts); + this.uitype='checkbox'; this.valueField = opts.valueField || 'value'; this.textField = opts.textField || 'text'; this.value = this.opts.value || this.opts.defaultValue||[]; @@ -577,7 +577,6 @@ bricks.UiCheckBox =class extends bricks.UiType { } bricks.UiDate =class extends bricks.UiStr { - static uitype='date'; /* { max_date: @@ -586,6 +585,7 @@ bricks.UiDate =class extends bricks.UiStr { */ constructor(options){ super(options); + this.uitype='date'; this.opts_setup(); } opts_setup(){ @@ -601,7 +601,6 @@ bricks.UiDate =class extends bricks.UiStr { } bricks.UiText =class extends bricks.UiType { - static uitype='text'; /* { name: @@ -618,6 +617,7 @@ bricks.UiText =class extends bricks.UiType { opts.dynsize = opts.dynsize || true; opts.cfontsize = opts.cfontsize || 1; super(opts); + this.uitype='text'; this.build(); this.charsize_sizing(); } @@ -669,11 +669,11 @@ bricks.UiCode =class extends bricks.UiType { method: } */ - static uitype='code'; constructor(opts){ opts.cfontsize = opts.cfontsize||1; opts.dynsize = opts.dynsize || true; super(opts); + this.uitype='code'; this.data = this.opts.data; this.build(); } @@ -764,33 +764,28 @@ bricks._Input = class { this.uitypes = []; } - register(name, Klass){ + register(name, uitype,Klass){ if (! Klass){ bricks.debug('Klass not defined', name); return; } - if (! Klass.uitype){ - bricks.debug('uitype of Klass not defined', name); - return; - - } bricks.Factory.register(name, Klass); - this.uitypes[Klass.uitype] = Klass; + this.uitypes[uitype] = Klass; } factory(options){ - var klass = objget(this.uitypes, options.uitype); + var klass = this.uitypes[options.uitype]; if (klass){ return new klass(options); } - bricks.debug('create input for:', options.uitype, 'failed'); + bricks.debug('create input for:', options.uitype, 'failed', this.uitypes); return null; } } bricks.UiAudio =class extends bricks.UiStr { - static uitype = 'audio'; constructor(opts){ super(opts); + this.uitype = 'audio'; this.autoplay = opts.autoplay; this.readonly = opts.readonly; this.icon = new bricks.Icon({ @@ -823,9 +818,9 @@ bricks.UiAudio =class extends bricks.UiStr { } } bricks.UiVideo =class extends bricks.UiStr { - static uitype = 'video'; constructor(opts){ super(opts); + this.uitype = 'video'; this.autoplay = opts.autoplay; this.readonly = opts.readonly; this.icon = new bricks.Icon({ @@ -858,20 +853,20 @@ bricks.UiVideo =class extends bricks.UiStr { } } var Input = new bricks._Input(); -Input.register('UiStr', bricks.UiStr); -Input.register('UiHide', bricks.UiHide); -Input.register('UiTel', bricks.UiTel); -Input.register('UiDate', bricks.UiDate); -Input.register('UiInt', bricks.UiInt); -Input.register('UiFloat', bricks.UiFloat); -Input.register('UiCheck', bricks.UiCheck); -Input.register('UiCheckBox', bricks.UiCheckBox); -Input.register('UiEmail', bricks.UiEmail); -Input.register('UiFile', bricks.UiFile); -Input.register('UiImage', bricks.UiImage); -Input.register('UiCode', bricks.UiCode); -Input.register('UiText', bricks.UiText); -Input.register('UiPassword', bricks.UiPassword); -Input.register('UiAudio', bricks.UiAudio); -Input.register('UiVideo', bricks.UiVideo); -Input.register('UiAudioText', bricks.UiAudioText); +Input.register('UiStr', 'str', bricks.UiStr); +Input.register('UiHide', 'hide', bricks.UiHide); +Input.register('UiTel', 'tel', bricks.UiTel); +Input.register('UiDate', 'date', bricks.UiDate); +Input.register('UiInt', 'int', bricks.UiInt); +Input.register('UiFloat', 'float', bricks.UiFloat); +Input.register('UiCheck', 'check', bricks.UiCheck); +Input.register('UiCheckBox', 'checkbox', bricks.UiCheckBox); +Input.register('UiEmail', 'email', bricks.UiEmail); +Input.register('UiFile', 'file', bricks.UiFile); +Input.register('UiImage', 'image', bricks.UiImage); +Input.register('UiCode', 'code', bricks.UiCode); +Input.register('UiText', 'text', bricks.UiText); +Input.register('UiPassword', 'password', bricks.UiPassword); +Input.register('UiAudio', 'audio', bricks.UiAudio); +Input.register('UiVideo', 'video', bricks.UiVideo); +Input.register('UiAudioText', 'audiotext', bricks.UiAudioText); diff --git a/bricks/markdown_viewer.js b/bricks/markdown_viewer.js index ae78507..46bcf4a 100755 --- a/bricks/markdown_viewer.js +++ b/bricks/markdown_viewer.js @@ -140,7 +140,7 @@ bricks.MarkdownViewer = class extends bricks.VBox { async build(){ await this._build(this.opts.md_url); } - assync _build(md_url){ + async _build(md_url){ var md_content = await (bricks.tget(md_url)); this.md_el.innerHTML = marked.parse(md_content); // this.md_el.baseURI = md_url;