This commit is contained in:
yumoqing 2024-02-28 11:49:58 +08:00
parent 81a82f46df
commit 638e629cf1
5 changed files with 57 additions and 20 deletions

View File

@ -91,11 +91,12 @@ bricks.widgetBuild = async function(desc, widget){
return null; return null;
} }
desc.options.baseURI = base_url; desc.options.baseURI = base_url;
let w = new klass(desc.options); var options = desc.options || {};
if (desc.hasOwnProperty('id')){ let w = new klass(options);
if (desc.id){
w.set_id(desc.id); w.set_id(desc.id);
} }
if (desc.hasOwnProperty('subwidgets')){ if (desc.subwidgets){
for (let i=0; i<desc.subwidgets.length; i++){ for (let i=0; i<desc.subwidgets.length; i++){
let sdesc = desc.subwidgets[i]; let sdesc = desc.subwidgets[i];
let sw = await (bricks.widgetBuild(sdesc, w)); let sw = await (bricks.widgetBuild(sdesc, w));
@ -213,6 +214,23 @@ bricks.getRealtimeData = function(w, desc){
return null; return null;
} }
var _buildWidget = async function(from_widget, target, mode, options){
console.log('target=', target, 'mode=', mode, 'options=', options);
var w = await (bricks.widgetBuild(options, from_widget));
if (!w){
console.log('options=', options, 'widgetBuild() failed');
return;
}
if (mode == 'replace'){
target.clear_widgets();
target.add_widget(w);
} else if (mode == 'insert'){
target.add_widget(w, 0);
} else {
target.add_widget(w);
}
}
bricks.buildUrlwidgetHandler = function(w, target, rtdata, desc){ bricks.buildUrlwidgetHandler = function(w, target, rtdata, desc){
var f = async function(target, mode, options){ var f = async function(target, mode, options){
console.log('target=', target, 'mode=', mode, 'options=', options); console.log('target=', target, 'mode=', mode, 'options=', options);
@ -223,16 +241,20 @@ bricks.buildUrlwidgetHandler = function(w, target, rtdata, desc){
} }
if (mode == 'replace'){ if (mode == 'replace'){
target.clear_widgets(); target.clear_widgets();
target.add_widget(w);
} else if (mode == 'insert'){
target.add_widget(w, 0);
} else {
target.add_widget(w);
} }
target.add_widget(w);
} }
var options = objcopy(desc.options); var options = objcopy(desc.options||{});
bricks.extend(options.params, rtdata); bricks.extend(options.params, rtdata);
var opts = { var opts = {
"widgettype":"urlwidget", "widgettype":"urlwidget",
"options":options "options":options
} }
return f.bind(target, target, desc.mode || 'replace', opts); return _buildWidget.bind(w, target, target, desc.mode || 'replace', opts);
} }
bricks.buildBricksHandler = function(w, target, rtdata, desc){ bricks.buildBricksHandler = function(w, target, rtdata, desc){
var f = async function(target, mode, options){ var f = async function(target, mode, options){
@ -247,9 +269,9 @@ bricks.buildBricksHandler = function(w, target, rtdata, desc){
} }
target.add_widget(w); target.add_widget(w);
} }
var options = objcopy(desc.options); var options = objcopy(desc.options||{});
bricks.extend(options.options, rtdata); bricks.extend(options.options, rtdata);
return f.bind(target, target, desc.mode || 'replace', options); return _buildWidget.bind(w, target, target, desc.mode || 'replace', options);
} }
bricks.buildRegisterFunctionHandler = function(w, target, rtdata, desc){ bricks.buildRegisterFunctionHandler = function(w, target, rtdata, desc){
var f = objget(registerfunctions, desc.rfname); var f = objget(registerfunctions, desc.rfname);
@ -269,7 +291,7 @@ bricks.buildRegisterFunctionHandler = function(w, target, rtdata, desc){
bricks.buildMethodHandler = function(w, target, rtdata, desc){ bricks.buildMethodHandler = function(w, target, rtdata, desc){
var f = target[desc.method]; var f = target[desc.method];
if (! f){ if (! f){
console.log('method:', desc.method, 'not exists in', target, 'w=', w); console.log('desc:', 'not exists in', target, 'w=', w);
return null; return null;
} }
var params = {}; var params = {};

View File

@ -60,6 +60,7 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
} }
render(params) { render(params) {
console.log('params=', params, 'render() called');
this.clear_widgets(); this.clear_widgets();
this.pages = new Map(); // 用于存储已加载的页面数据 this.pages = new Map(); // 用于存储已加载的页面数据
this.pageContents = new Map(); // 用于存储已加载的页面内容 this.pageContents = new Map(); // 用于存储已加载的页面内容
@ -143,7 +144,7 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
}); });
content.set_css('accordion-item-content'); content.set_css('accordion-item-content');
content.hide(); content.hide();
header.bind('click', this.toggle_content.bind(this, content, record)); header.bind('click', this.toggle_content.bind(this, header, content, record));
item.add_widget(header); item.add_widget(header);
item.add_widget(content); item.add_widget(content);
pageContent.add_widget(item); pageContent.add_widget(item);
@ -157,7 +158,9 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
this.add_widget(pageContent); this.add_widget(pageContent);
} }
} }
async toggle_content(content, record, event){ async toggle_content(header, content, record, event){
var h = this.dom_element.offsetHeight - 3 * header.dom_element.offsetHeight;
content.set_style('height', h + 'px');
if (this.active_content){ if (this.active_content){
if (this.active_content != content){ if (this.active_content != content){
this.active_content.clear_widgets(); this.active_content.clear_widgets();

View File

@ -123,16 +123,13 @@ bricks.UiStr =class extends bricks.UiType {
return v[0]; return v[0];
} }
set_value_from_input(event){ set_value_from_input(event){
var oldv = this.value;
var changed = false;
var e = event.target; var e = event.target;
if (e.value == ''){ var v = e.value;
this.value = ''; if (e.value!='' && e.type != 'file'){
return v = this.check_pattern(e.value);
}
if (e.type == 'file'){
this.value = e.value;
return;
} }
var v = this.check_pattern(e.value);
if (v == null){ if (v == null){
e.value = this.value; e.value = this.value;
return return

View File

@ -31,15 +31,30 @@ bricks.Video = class extends bricks.Layout {
e.controls = true; e.controls = true;
this.dom_element = e; this.dom_element = e;
} }
disable_captions(){
this.player.nativeTextTracks = false;
var tt = this.player.textTracks()
console.log('textTracks=', tt);
if (tt){
for(var i=0;i<tt.length;i++){
tt[i].mode = 'disabled';
}
}
}
auto_play(){ auto_play(){
this.hidedbtn.dispatch('click'); this.hidedbtn.dispatch('click');
schedule_once(this.disable_captions.bind(this), 2);
} }
play(){ play(){
this.player.play(); this.player.play();
} }
create_player(){ create_player(){
console.log('here2'); console.log('here2');
this.player = videojs(this.dom_element); this.player = videojs(this.dom_element, {
textTrackSettings: false
});
this.player.ready(this.auto_play.bind(this));
this._set_source(); this._set_source();
if (this.opts.autoplay){ if (this.opts.autoplay){
// schedule_once(this.auto_play.bind(this), 0.1); // schedule_once(this.auto_play.bind(this), 0.1);

Binary file not shown.