From 04881aa4d6d52954d26e0b02bd2d12112de2046f Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 17 Feb 2024 20:18:18 +0800 Subject: [PATCH] bugfix --- bricks/accordion.js | 2 +- bricks/bricks.js | 5 +++-- bricks/input.js | 20 ++++++++++++++++++-- examples/m3u8.ui | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/bricks/accordion.js b/bricks/accordion.js index a28441f..45bbe5e 100644 --- a/bricks/accordion.js +++ b/bricks/accordion.js @@ -55,7 +55,7 @@ bricks.Accordion = class oops extends bricks.VBox { } var c = objget(this.subcontents,name); if (! c){ - c = await widgetBuild(this.opts.items[pos].content); + c = await bricks.widgetBuild(this.opts.items[pos].content); this.subcontents[name] = c; } this.content.clear_widgets(); diff --git a/bricks/bricks.js b/bricks/bricks.js index 0152589..212c666 100755 --- a/bricks/bricks.js +++ b/bricks/bricks.js @@ -196,16 +196,17 @@ bricks.buildEventHandler = function(w, desc){ bricks.getRealtimeData = function(w, desc){ var target = bricks.getWidgetById(desc.widget, w); var f; + console.log('getRealtimeData() calling ...'); if (! target){ console.log('target miss', desc); return null } if (desc.method){ - f = buildMethodHandler(null, target, null, desc) + f = bricks.buildMethodHandler(null, target, null, desc) return f(); } if (desc.script){ - f = buildScriptHandler(null, target, null, desc) + f = bricks.buildScriptHandler(null, target, null, desc) return f(); } debug('getRealtimeData():desc=', desc, 'f=', f); diff --git a/bricks/input.js b/bricks/input.js index 3f6a2ba..3919d7f 100755 --- a/bricks/input.js +++ b/bricks/input.js @@ -74,7 +74,7 @@ bricks.UiStr =class extends bricks.UiType { this.dom_element = el; this.pattern = '.*'; el.type = 'text'; - el.id = el.name = this.opts.name; + el.id = this.name = el.name = this.opts.name; if (this.opts.required) el.required = true; if (this.opts.css){ @@ -90,22 +90,30 @@ bricks.UiStr =class extends bricks.UiType { if (this.opts.hasOwnProperty('minlength')) el.minlength = this.opts.minlength; if (this.opts.hasOwnProperty('value')) - this.value = this.opts.value; + this.setValue(this.opts.value); if (this.opts.defaultVlaue) el.defaultValue = this.opts.defaultValue; this.reset() if (this.opts.tip) el.placeholder = bricks.app.i18n._(this.opts.tip); el.addEventListener('focus', this.onfocus.bind(this)); + el.addEventListener('onkeydown', this.onkeydown.bind(this)); el.addEventListener('blur', this.onblur.bind(this)); el.addEventListener('input', this.set_value_from_input.bind(this)) } onblur(event){ this.dom_element.classList.remove(this.actived_css); + this.value = this.dom_element.value; + this.set_value_from_input(event); } onfocus(event){ this.dom_element.classList.add(this.actived_css); } + onkeydown(event){ + if(event.key == 'Enter'){ + this.dispatch('blur', ) + } + } check_pattern(value){ var r = new RegExp(this.pattern); var v = value.match(r); @@ -134,8 +142,16 @@ bricks.UiStr =class extends bricks.UiType { this.dispatch('changed', o); } resultValue(){ + this.value = this.dom_element.value; return this.value; } + getValue(){ + this.value = this.dom_element.value; + var k = this.name; + var d = {} + d[this.name] = this.value; + return d; + } setValue(v){ if (! v) v = ''; diff --git a/examples/m3u8.ui b/examples/m3u8.ui index 0b3dce6..7bb61cd 100644 --- a/examples/m3u8.ui +++ b/examples/m3u8.ui @@ -4,7 +4,7 @@ "widgettype":"VideoPlayer", "options":{ "autoplay":true, - "url":"https://abc-iview-mediapackagestreams-2.akamaized.net/out/v1/6e1cc6d25ec0480ea099a5399d73bc4b/index.m3u8", + "url":"{{params_kw.get('url')}}", "type":"hls" } }