This commit is contained in:
yumoqing 2024-02-17 20:18:18 +08:00
parent dfa98941a0
commit 04881aa4d6
4 changed files with 23 additions and 6 deletions

View File

@ -55,7 +55,7 @@ bricks.Accordion = class oops extends bricks.VBox {
} }
var c = objget(this.subcontents,name); var c = objget(this.subcontents,name);
if (! c){ if (! c){
c = await widgetBuild(this.opts.items[pos].content); c = await bricks.widgetBuild(this.opts.items[pos].content);
this.subcontents[name] = c; this.subcontents[name] = c;
} }
this.content.clear_widgets(); this.content.clear_widgets();

View File

@ -196,16 +196,17 @@ bricks.buildEventHandler = function(w, desc){
bricks.getRealtimeData = function(w, desc){ bricks.getRealtimeData = function(w, desc){
var target = bricks.getWidgetById(desc.widget, w); var target = bricks.getWidgetById(desc.widget, w);
var f; var f;
console.log('getRealtimeData() calling ...');
if (! target){ if (! target){
console.log('target miss', desc); console.log('target miss', desc);
return null return null
} }
if (desc.method){ if (desc.method){
f = buildMethodHandler(null, target, null, desc) f = bricks.buildMethodHandler(null, target, null, desc)
return f(); return f();
} }
if (desc.script){ if (desc.script){
f = buildScriptHandler(null, target, null, desc) f = bricks.buildScriptHandler(null, target, null, desc)
return f(); return f();
} }
debug('getRealtimeData():desc=', desc, 'f=', f); debug('getRealtimeData():desc=', desc, 'f=', f);

View File

@ -74,7 +74,7 @@ bricks.UiStr =class extends bricks.UiType {
this.dom_element = el; this.dom_element = el;
this.pattern = '.*'; this.pattern = '.*';
el.type = 'text'; el.type = 'text';
el.id = el.name = this.opts.name; el.id = this.name = el.name = this.opts.name;
if (this.opts.required) if (this.opts.required)
el.required = true; el.required = true;
if (this.opts.css){ if (this.opts.css){
@ -90,22 +90,30 @@ bricks.UiStr =class extends bricks.UiType {
if (this.opts.hasOwnProperty('minlength')) if (this.opts.hasOwnProperty('minlength'))
el.minlength = this.opts.minlength; el.minlength = this.opts.minlength;
if (this.opts.hasOwnProperty('value')) if (this.opts.hasOwnProperty('value'))
this.value = this.opts.value; this.setValue(this.opts.value);
if (this.opts.defaultVlaue) if (this.opts.defaultVlaue)
el.defaultValue = this.opts.defaultValue; el.defaultValue = this.opts.defaultValue;
this.reset() this.reset()
if (this.opts.tip) if (this.opts.tip)
el.placeholder = bricks.app.i18n._(this.opts.tip); el.placeholder = bricks.app.i18n._(this.opts.tip);
el.addEventListener('focus', this.onfocus.bind(this)); el.addEventListener('focus', this.onfocus.bind(this));
el.addEventListener('onkeydown', this.onkeydown.bind(this));
el.addEventListener('blur', this.onblur.bind(this)); el.addEventListener('blur', this.onblur.bind(this));
el.addEventListener('input', this.set_value_from_input.bind(this)) el.addEventListener('input', this.set_value_from_input.bind(this))
} }
onblur(event){ onblur(event){
this.dom_element.classList.remove(this.actived_css); this.dom_element.classList.remove(this.actived_css);
this.value = this.dom_element.value;
this.set_value_from_input(event);
} }
onfocus(event){ onfocus(event){
this.dom_element.classList.add(this.actived_css); this.dom_element.classList.add(this.actived_css);
} }
onkeydown(event){
if(event.key == 'Enter'){
this.dispatch('blur', )
}
}
check_pattern(value){ check_pattern(value){
var r = new RegExp(this.pattern); var r = new RegExp(this.pattern);
var v = value.match(r); var v = value.match(r);
@ -134,8 +142,16 @@ bricks.UiStr =class extends bricks.UiType {
this.dispatch('changed', o); this.dispatch('changed', o);
} }
resultValue(){ resultValue(){
this.value = this.dom_element.value;
return this.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){ setValue(v){
if (! v) if (! v)
v = ''; v = '';

View File

@ -4,7 +4,7 @@
"widgettype":"VideoPlayer", "widgettype":"VideoPlayer",
"options":{ "options":{
"autoplay":true, "autoplay":true,
"url":"https://abc-iview-mediapackagestreams-2.akamaized.net/out/v1/6e1cc6d25ec0480ea099a5399d73bc4b/index.m3u8", "url":"{{params_kw.get('url')}}",
"type":"hls" "type":"hls"
} }
} }