This commit is contained in:
yumoqing 2024-03-08 10:54:16 +08:00
parent 15e64a16f9
commit 278a520138
27 changed files with 223 additions and 166 deletions

View File

@ -42,7 +42,7 @@ bricks.Accordion = class oops extends bricks.VBox {
async change_content(evnet){ async change_content(evnet){
var b = event.target.bricks_widget; var b = event.target.bricks_widget;
var name = b.opts.name; var name = b.opts.name;
console.log('accordion: button=', b, 'name=', name); bricks.debug('accordion: button=', b, 'name=', name);
var pos = -1; var pos = -1;
for (var i=0; i< this.opts.items.length; i++){ for (var i=0; i< this.opts.items.length; i++){
if (name == this.opts.items[i].name){ if (name == this.opts.items[i].name){

View File

@ -41,6 +41,6 @@ bricks.AG_Grid = class oops extends bricks.JsWidget {
}); });
} }
cell_clicked(params){ cell_clicked(params){
console.log('clicked, params=', params); bricks.debug('clicked, params=', params);
} }
} }

View File

@ -36,7 +36,7 @@ bricks.AudioPlayer = class oops extends bricks.JsWidget {
} }
set_source(url){ set_source(url){
this.audio.src = url; this.audio.src = url;
console.log(this.audio.src,' new src seted'); bricks.debug(this.audio.src,' new src seted');
} }
play(){ play(){
this.audio.play(); this.audio.play();
@ -84,7 +84,7 @@ bricks.AudioRecorder = class oops extends bricks.HBox {
this.bind('record_finished', this.upload.bind(this)); this.bind('record_finished', this.upload.bind(this));
} }
rec_btn_pressed(){ rec_btn_pressed(){
console.log(this.rec_btn.url, ':url:', this.start_icon, this.stop_icon); bricks.debug(this.rec_btn.url, ':url:', this.start_icon, this.stop_icon);
if(this.rec_btn.url == this.start_icon){ if(this.rec_btn.url == this.start_icon){
this.rec_btn.set_url(this.stop_icon); this.rec_btn.set_url(this.stop_icon);
this.start_recording(); this.start_recording();
@ -119,7 +119,7 @@ bricks.AudioRecorder = class oops extends bricks.HBox {
//此处创建这些音频可视化图形绘制浏览器支持妥妥的 //此处创建这些音频可视化图形绘制浏览器支持妥妥的
//this.wave=Recorder.FrequencyHistogramView({elem:".recwave"}); //this.wave=Recorder.FrequencyHistogramView({elem:".recwave"});
}.bind(this),function(msg,isUserNotAllow){//用户拒绝未授权或不支持 }.bind(this),function(msg,isUserNotAllow){//用户拒绝未授权或不支持
console.log('open recorder failed'); bricks.debug('open recorder failed');
}); });
} }
recClose(){ recClose(){
@ -128,7 +128,7 @@ bricks.AudioRecorder = class oops extends bricks.HBox {
this.rec = null; this.rec = null;
this.mic_opened = false; this.mic_opened = false;
}else{ }else{
console.log('close recorder error'); bricks.debug('close recorder error');
}; };
} }
recoding(){ recoding(){
@ -149,19 +149,19 @@ bricks.AudioRecorder = class oops extends bricks.HBox {
if(this.rec&&Recorder.IsOpen()){ if(this.rec&&Recorder.IsOpen()){
this.rec.pause(); this.rec.pause();
}else{ }else{
console.log("gCAR::未打开录音"); bricks.debug("gCAR::未打开录音");
}; };
} }
resume_recording(){ resume_recording(){
if(this.rec&&Recorder.IsOpen()){ if(this.rec&&Recorder.IsOpen()){
this.rec.resume(); this.rec.resume();
}else{ }else{
console.log("Ob6S::未打开录音"); bricks.debug("Ob6S::未打开录音");
}; };
} }
stop_recording(){ stop_recording(){
if(!(this.rec&&Recorder.IsOpen())){ if(!(this.rec&&Recorder.IsOpen())){
console.log("5JuL::未打开录音"); bricks.debug("5JuL::未打开录音");
return; return;
}; };
this.rec.stop(function(blob,duration){ this.rec.stop(function(blob,duration){
@ -176,32 +176,32 @@ bricks.AudioRecorder = class oops extends bricks.HBox {
this.dispatch('record_finished', d); this.dispatch('record_finished', d);
}.bind(this),function(msg){ }.bind(this),function(msg){
console.log("kGZO::录音失败:"); bricks.debug("kGZO::录音失败:");
}); });
} }
upload = async function(){ upload = async function(){
if(!this.recordData){ if(!this.recordData){
console.log("DUTn::请先录音,然后停止后再上传"); bricks.debug("DUTn::请先录音,然后停止后再上传");
return; return;
}; };
if(!this.upload_url){ if(!this.upload_url){
return; return;
} }
var blob=this.recordData.data; var blob=this.recordData.data;
console.log('blob=', blob, this.recordData); bricks.debug('blob=', blob, this.recordData);
var form=new FormData(); var form=new FormData();
form.append("audiofile",blob,"recorder.wav"); form.append("audiofile",blob,"recorder.wav");
var jpost = bricks.jpost var jpost = bricks.jpost
var ret = await jpost(this.upload_url,{ var ret = await jpost(this.upload_url,{
params:form params:form
}); });
console.log('ret=', ret); bricks.debug('ret=', ret);
this.recClose(); this.recClose();
this.dispatch('updated', ret) this.dispatch('updated', ret)
} }
download(){ download(){
if(!this.recordData){ if(!this.recordData){
console.log('recorder not opened'); bricks.debug('recorder not opened');
return; return;
}; };
var fileName="recorder-"+Date.now()+".wav"; var fileName="recorder-"+Date.now()+".wav";
@ -211,7 +211,7 @@ bricks.AudioRecorder = class oops extends bricks.HBox {
downA.download=fileName; downA.download=fileName;
// document.querySelector("."+cls).appendChild(downA); // document.querySelector("."+cls).appendChild(downA);
if(/mobile/i.test(navigator.userAgent)){ if(/mobile/i.test(navigator.userAgent)){
console.log('mobile device'); bricks.debug('mobile device');
} }
downA.click(); downA.click();
//不用了时需要revokeObjectURL否则霸占内存 //不用了时需要revokeObjectURL否则霸占内存

View File

@ -87,7 +87,7 @@ bricks.widgetBuild = async function(desc, widget){
} }
let klass = bricks.Factory.get(desc.widgettype); let klass = bricks.Factory.get(desc.widgettype);
if (! klass){ if (! klass){
console.log('widgetBuild():',desc.widgettype, 'not registered', bricks.Factory.widgets_kw); bricks.debug('widgetBuild():',desc.widgettype, 'not registered', bricks.Factory.widgets_kw);
return null; return null;
} }
var options = desc.options || {}; var options = desc.options || {};
@ -103,7 +103,7 @@ bricks.widgetBuild = async function(desc, widget){
if ( sw ){ if ( sw ){
w.add_widget(sw); w.add_widget(sw);
} else { } else {
console.log('widgetBuild() error: sdesc=', sdesc); bricks.debug('widgetBuild() error: sdesc=', sdesc);
} }
} }
} }
@ -141,7 +141,7 @@ bricks.universal_handler = function(from_widget, widget, desc, event){
if (f){ if (f){
return f(event); return f(event);
} }
console.log('universal_handler() error', 'from_widget=', bricks.debug('universal_handler() error', 'from_widget=',
from_widget, from_widget,
'widget=', widget, 'widget=', widget,
'desc=', desc, 'desc=', desc,
@ -150,7 +150,7 @@ bricks.universal_handler = function(from_widget, widget, desc, event){
bricks.buildEventHandler = function(w, desc){ bricks.buildEventHandler = function(w, desc){
var target = bricks.getWidgetById(desc.target, w); var target = bricks.getWidgetById(desc.target, w);
if (! target){ if (! target){
console.log('target miss desc=', desc, 'w=', w); bricks.debug('target miss desc=', desc, 'w=', w);
return null return null
} }
var rtdata = null; var rtdata = null;
@ -185,16 +185,16 @@ bricks.buildEventHandler = function(w, desc){
return bricks.buildDispatchEventHandler(w, target, rtdata, desc); return bricks.buildDispatchEventHandler(w, target, rtdata, desc);
break; break;
default: default:
console.log('invalid actiontype', target, desc); bricks.debug('invalid actiontype', target, desc);
break; break;
} }
} }
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 ...'); bricks.debug('getRealtimeData() calling ...');
if (! target){ if (! target){
console.log('target miss', desc); bricks.debug('target miss', desc);
return null return null
} }
if (desc.method){ if (desc.method){
@ -210,10 +210,10 @@ bricks.getRealtimeData = function(w, desc){
} }
var _buildWidget = async function(from_widget, target, mode, options){ var _buildWidget = async function(from_widget, target, mode, options){
console.log('target=', target, 'mode=', mode, 'options=', options); bricks.debug('target=', target, 'mode=', mode, 'options=', options);
var w = await (bricks.widgetBuild(options, from_widget)); var w = await (bricks.widgetBuild(options, from_widget));
if (!w){ if (!w){
console.log('options=', options, 'widgetBuild() failed'); bricks.debug('options=', options, 'widgetBuild() failed');
return; return;
} }
if (mode == 'replace'){ if (mode == 'replace'){
@ -228,10 +228,10 @@ var _buildWidget = async function(from_widget, target, mode, options){
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); bricks.debug('target=', target, 'mode=', mode, 'options=', options);
var w = await (bricks.widgetBuild(options, w)); var w = await (bricks.widgetBuild(options, w));
if (!w){ if (!w){
console.log('options=', options, 'widgetBuild() failed'); bricks.debug('options=', options, 'widgetBuild() failed');
return; return;
} }
if (mode == 'replace'){ if (mode == 'replace'){
@ -253,10 +253,10 @@ bricks.buildUrlwidgetHandler = function(w, target, rtdata, desc){
} }
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){
console.log('target=', target, 'mode=', mode, 'options=', options); bricks.debug('target=', target, 'mode=', mode, 'options=', options);
var w = await (bricks.widgetBuild(options, wa)); var w = await (bricks.widgetBuild(options, wa));
if (!w){ if (!w){
console.log('options=', options, 'widgetBuild() failed'); bricks.debug('options=', options, 'widgetBuild() failed');
return; return;
} }
if (mode == 'replace'){ if (mode == 'replace'){
@ -271,7 +271,7 @@ bricks.buildBricksHandler = function(w, target, rtdata, desc){
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);
if( ! f){ if( ! f){
console.log('rfname:', desc.rfname, 'not registed', desc); bricks.debug('rfname:', desc.rfname, 'not registed', desc);
return null; return null;
} }
var params = {}; var params = {};
@ -286,7 +286,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('desc:', desc, 'not exists in', target, 'w=', w); bricks.debug('desc:', desc, 'not exists in', target, 'w=', w);
return null; return null;
} }
var params = {}; var params = {};
@ -299,7 +299,7 @@ bricks.buildScriptHandler = function(w, target, rtdata, desc){
bricks.extend(params, desc.params) bricks.extend(params, desc.params)
bricks.extend(params, rtdata); bricks.extend(params, rtdata);
var f = new Function('target', 'params', 'event', desc.script); var f = new Function('target', 'params', 'event', desc.script);
console.log('params=', params, 'buildScriptHandler() ..........'); bricks.debug('params=', params, 'buildScriptHandler() ..........');
return f.bind(target, target, params); return f.bind(target, target, params);
} }
bricks.buildDispatchEventHandler = function(w, target, rtdata, desc){ bricks.buildDispatchEventHandler = function(w, target, rtdata, desc){
@ -352,11 +352,11 @@ bricks.getWidgetById = function(id, from_widget){
} }
} }
catch(err){ catch(err){
console.log('getWidgetById():i=', ids[i], id, 'not found', err); bricks.debug('getWidgetById():i=', ids[i], id, 'not found', err);
return null; return null;
} }
if ( new_el == null ){ if ( new_el == null ){
console.log('getWidgetById():', id, from_widget, 'el=', el, 'id=', ids[i]); bricks.debug('getWidgetById():', id, from_widget, 'el=', el, 'id=', ids[i]);
return null; return null;
} }
el = new_el; el = new_el;
@ -364,7 +364,7 @@ bricks.getWidgetById = function(id, from_widget){
if (typeof(el.bricks_widget) !== 'undefined'){ if (typeof(el.bricks_widget) !== 'undefined'){
return el.bricks_widget; return el.bricks_widget;
} }
console.log('********', id, 'el=', el, 'found, but not a bricks class with dom element'); bricks.debug('********', id, 'el=', el, 'found, but not a bricks class with dom element');
return el; return el;
} }
@ -425,7 +425,7 @@ bricks.App = class extends bricks.Layout {
var opts = structuredClone(this.opts.widget); var opts = structuredClone(this.opts.widget);
var w = await (bricks.widgetBuild(opts, bricks.Body)); var w = await (bricks.widgetBuild(opts, bricks.Body));
if (!w){ if (!w){
console.log('w=', w, 'Body=', bricks.Body, 'Factory=', bricks.Factory) bricks.debug('w=', w, 'Body=', bricks.Body, 'Factory=', bricks.Factory)
} }
return w; return w;
} }
@ -434,7 +434,7 @@ bricks.App = class extends bricks.Layout {
var w = await (this.build()); var w = await (this.build());
this.root = w; this.root = w;
if (!w){ if (!w){
console.log('w=', w, 'Body=', bricks.Body, 'Factory=', bricks.Factory) bricks.debug('w=', w, 'Body=', bricks.Body, 'Factory=', bricks.Factory)
return null; return null;
} }
bricks.Body.add_widget(w); bricks.Body.add_widget(w);

View File

@ -78,12 +78,12 @@ bricks.Button = class extends bricks.Layout {
} }
} }
target_clicked(event){ target_clicked(event){
console.log('target_clicked() .... called '); bricks.debug('target_clicked() .... called ');
event.stopPropagation(); event.stopPropagation();
this.dispatch('click', this.opts); this.dispatch('click', this.opts);
if (this.opts.action){ if (this.opts.action){
if (this.opts.debug){ if (this.opts.debug){
console.log('debug:opts=', this.opts); bricks.debug('debug:opts=', this.opts);
} }
} }
} }

View File

@ -283,7 +283,7 @@ bricks.DataGrid = class extends bricks.VBox {
} }
this.freeze_part = null; this.freeze_part = null;
this.normal_part = null; this.normal_part = null;
console.log('width=', this.freeze_width, '-', this.normal_width, '...'); bricks.debug('width=', this.freeze_width, '-', this.normal_width, '...');
if (this.freeze_fields.length > 0) { if (this.freeze_fields.length > 0) {
this.freeze_part = new bricks.VBox({}); this.freeze_part = new bricks.VBox({});
this.freeze_part.set_css('datagrid-left'); this.freeze_part.set_css('datagrid-left');
@ -325,11 +325,11 @@ bricks.DataGrid = class extends bricks.VBox {
} }
} }
load_previous_data() { load_previous_data() {
console.log('event min_threshold fired ........'); bricks.debug('event min_threshold fired ........');
this.loader.previousPage(); this.loader.previousPage();
} }
load_next_data() { load_next_data() {
console.log('event max_threshold fired ........'); bricks.debug('event max_threshold fired ........');
this.loader.nextPage(); this.loader.nextPage();
} }
coscroll(event) { coscroll(event) {
@ -378,7 +378,7 @@ bricks.DataGrid = class extends bricks.VBox {
this.selected_row = row; this.selected_row = row;
this.selected_row.selected(); this.selected_row.selected();
this.dispatch('row_click', row); this.dispatch('row_click', row);
console.log('DataGrid():click_handler, row=', row, 'event=', event); bricks.debug('DataGrid():click_handler, row=', row, 'event=', event);
} }
} }

View File

@ -40,7 +40,7 @@ bricks.DataViewer = class extends bricks.VScrollPanel {
fetch(this.opts.viewer_url) fetch(this.opts.viewer_url)
.then(response => response.text()) .then(response => response.text())
.then(data => { .then(data => {
console.log('viewer_tmpl=', data); bricks.debug('viewer_tmpl=', data);
this.viewer_tmpl = data this.viewer_tmpl = data
schedule_once(this.loader.loadData.bind(this.loader), 0.01); schedule_once(this.loader.loadData.bind(this.loader), 0.01);
}); });
@ -58,13 +58,13 @@ bricks.DataViewer = class extends bricks.VScrollPanel {
var desc = JSON.parse(s); var desc = JSON.parse(s);
var w = await bricks.widgetBuild(desc, this); var w = await bricks.widgetBuild(desc, this);
if (! w){ if (! w){
console.log(desc, 'widgetBuild() failed...........'); bricks.debug(desc, 'widgetBuild() failed...........');
return; return;
} }
w.row_data = row; w.row_data = row;
var index = null; var index = null;
if (direction == 'down') index = 0; if (direction == 'down') index = 0;
console.log('w=', w, 'this=', this); bricks.debug('w=', w, 'this=', this);
this.add_widget(w, index); this.add_widget(w, index);
} }
} }

View File

@ -56,24 +56,24 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
} }
this.bind('min_threshold', this.load_previous_page.bind(this)); this.bind('min_threshold', this.load_previous_page.bind(this));
this.bind('max_threshold', this.load_next_page.bind(this)); this.bind('max_threshold', this.load_next_page.bind(this));
this.oldscrollY = null;
this.render(); this.render();
} }
render(params) { render(params) {
console.log('params=', params, 'render() called'); bricks.debug('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(); // 用于存储已加载的页面内容
params = params || {}; params = params || {};
this.params = bricks.extend(this.base_params, params); this.params = bricks.extend(this.base_params, params);
this.loadPage(1); this.loadPage(1);
this.dom_element.scrollTop = 0;
} }
async loadPage(page) { async loadPage(page) {
if (this.loading){
return;
}
this.loading = true;
// 检查页面是否在缓存中 // 检查页面是否在缓存中
if (! this.pages.has(page)) { if (! this.pages.has(page)) {
var jc = new bricks.HttpJson(); var jc = new bricks.HttpJson();
@ -84,7 +84,7 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
}); });
var d = await jc.get(this.dataUrl,{params:params}); var d = await jc.get(this.dataUrl,{params:params});
if (!d){ if (!d){
console.log(this.dataUrl,{params:params}, 'error'); bricks.debug(this.dataUrl,{params:params}, 'error');
this.loading = false; this.loading = false;
return; return;
} }
@ -100,30 +100,30 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
max = Math.max(...pages); max = Math.max(...pages);
min = Math.min(...pages); min = Math.min(...pages);
const farthestPage = page == max? min : max; const farthestPage = page == max? min : max;
var w = this.pageContents.get(farthestPage); this.delete_page(farthestPage);
this.remove_widget(w);
this.pages.delete(farthestPage); this.pages.delete(farthestPage);
this.pageContents.delete(farthestPage);
}
var pages = Array.from(this.pages.keys());
if (page == Math.min(pages)){
this.scrollY = 1 / pages.length;
if (this.scrollY == 1){
this.scrollY = 0;
}
} else {
this.scrollY = (pages.length - 1) / pages.length;
} }
} else {
bricks.debug(page, 'already n buffer, do not thing');
} }
this.loading = false;
return; return;
} }
is_max_page(page){
const pages = Array.from(this.pages.keys());
return page == Math.max(...pages);
}
is_min_page(page){
const pages = Array.from(this.pages.keys());
return page == Math.min(...pages);
}
async renderAccordionItems(data, page) { async renderAccordionItems(data, page) {
var pos;
const pageContent = new bricks.PageContent({height:"auto"});
pageContent.page = page;
for (var i=0;i<data.length;i++){ for (var i=0;i<data.length;i++){
if (this.is_max_page(page)){
pos = -1;
} else {
pos = i;
}
const record = data[i]; const record = data[i];
const item = new bricks.AccordionItem({}); const item = new bricks.AccordionItem({});
const header = new bricks.AccordionHeader({}); const header = new bricks.AccordionHeader({});
@ -134,7 +134,7 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
if (w){ if (w){
header.add_widget(w); header.add_widget(w);
} else { } else {
console.log('bricks.widgetBuildWithData(), tmpl=', this.record_view_tmpl, 'record=', record); bricks.debug('bricks.widgetBuildWithData(), tmpl=', this.record_view_tmpl, 'record=', record);
} }
} }
header.textContent = record.title; // 使用数据记录的标题字段 header.textContent = record.title; // 使用数据记录的标题字段
@ -147,17 +147,23 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
header.bind('click', this.toggle_content.bind(this, header, 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); item.set_attribute('data-page', page);
this.add_widget(item, pos);
if (pos >= 0){
this.dom_element.scrollTop += item.get_height();
} else {
this.dom_element.scrollTop -= item.get_height();
}
}; };
}
this.pageContents.set(page, pageContent); delete_page(page){
var pages = Array.from(this.pages.keys()); var items = this.dom_element.querySelectorAll('[data-page="' + page + '"]');
if (page == Math.min(...pages)){ for (var i=0;i<items.length;i++) {
this.add_widget(pageContent, 0); var w = items[i].bricks_widget;
} else { this.remove_widget(w);
this.add_widget(pageContent);
} }
} }
async toggle_content(header, content, record, event){ async toggle_content(header, content, record, event){
var h = this.dom_element.offsetHeight - 3 * header.dom_element.offsetHeight; var h = this.dom_element.offsetHeight - 3 * header.dom_element.offsetHeight;
content.set_style('height', h + 'px'); content.set_style('height', h + 'px');
@ -170,7 +176,7 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
} }
content.toggle_hide(); content.toggle_hide();
if (content.dom_element.style.display == 'none'){ if (content.dom_element.style.display == 'none'){
console.log('content just collapsed'); bricks.debug('content just collapsed');
content.clear_widgets(); content.clear_widgets();
this.active_content = null; this.active_content = null;
return; return;
@ -199,44 +205,69 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
} }
get_load_page(dir){ get_load_page(dir){
var pages = Array.from(this.pages.keys()); var pages = Array.from(this.pages.keys());
if (pages.length == 0){
return 1;
}
if (dir=='up'){ if (dir=='up'){
var page = Math.min(...pages); var page = Math.min(...pages);
console.log('page=', page, pages, 'dir=', dir); bricks.debug('page=', page, pages, 'dir=', dir);
return page - 1; return page - 1;
} else { } else {
var page = Math.max(...pages); var page = Math.max(...pages);
console.log('page=', page, pages, 'dir=', dir); bricks.debug('page=', page, pages, 'dir=', dir);
return page + 1; return page + 1;
} }
} }
async load_previous_page(){ async load_previous_page(){
var pages = Array.from(this.pages.keys()); if (this.loading){
var page = this.get_load_page('up'); bricks.debug('this.loading is set, do not thing');
if (page > 0){ return;
await this.loadPage(page);
console.log('page loaded, page=', page);
} else {
var pages = Array.from(this.pages.keys());
console.log('page NOT loaded, page=', page,
'lastPage=', this.lastPage,
'rows=', this.rows,
'cacheLimit=', this.cacheLimit,
'buffered page=', pages.length);
} }
this.loading = true;
try {
var page = this.get_load_page('up');
if (page > 0){
await this.loadPage(page);
var pages = Array.from(this.pages.keys());
bricks.debug('load_previous_page():page loaded, page=', page, pages);
} else {
var pages = Array.from(this.pages.keys());
bricks.debug('page NOT loaded, page=', page,
'lastPage=', this.lastPage,
'rows=', this.rows,
'cacheLimit=', this.cacheLimit,
'buffered page=', pages.length);
}
} catch(e){
bricks.debug('error happened', e);
}
this.loading = false;
} }
async load_next_page(){ async load_next_page(){
var pages = Array.from(this.pages.keys()); if (this.loading){
var page = this.get_load_page('down'); bricks.debug('this.loading is set, do not thing');
if (page <= this.lastPage){ return;
await this.loadPage(page);
console.log('page Loaded, page=', page);
} else {
console.log('page=', page,
'lastPage=', this.lastPage,
'rows=', this.rows,
'cacheLimit=', this.cacheLimit,
'buffered page=', pages);
} }
this.loading = true;
try {
var page = this.get_load_page('down');
if (page <= this.lastPage){
await this.loadPage(page);
var pages = Array.from(this.pages.keys());
bricks.debug('load_next_page():page Loaded, page=', page, pages);
} else {
var pages = Array.from(this.pages.keys());
bricks.debug('page=', page,
'lastPage=', this.lastPage,
'rows=', this.rows,
'cacheLimit=', this.cacheLimit,
'buffered page=', pages);
}
} catch (e){
bricks.debug('error happened', e);
}
this.loading = false;
bricks.debug('load_next_page() finished');
} }
} }
bricks.Factory.register('DynamicAccordion', bricks.DynamicAccordion); bricks.Factory.register('DynamicAccordion', bricks.DynamicAccordion);

View File

@ -36,7 +36,7 @@ bricks.FieldGroup = class extends bricks.VBox {
box.add_widget(w); box.add_widget(w);
form.name_inputs[fields[i].name] = w; form.name_inputs[fields[i].name] = w;
} else { } else {
console.log(fields[i], 'createInput failed'); bricks.debug(fields[i], 'createInput failed');
} }
} }
} }
@ -141,7 +141,7 @@ bricks.Form = class extends bricks.VBox {
} }
command_handle(event){ command_handle(event){
var params = event.params; var params = event.params;
console.log('Form(): click_handle() params=', params); bricks.debug('Form(): click_handle() params=', params);
if (!params){ if (!params){
error('click_handle() get a null params'); error('click_handle() get a null params');
return return
@ -181,7 +181,7 @@ bricks.Form = class extends bricks.VBox {
var w = this.name_inputs[name]; var w = this.name_inputs[name];
var d = w.getValue(); var d = w.getValue();
if (w.required && ( d[name] == '' || d[name] === null)){ if (w.required && ( d[name] == '' || d[name] === null)){
console.log('data=', data, 'd=', d); bricks.debug('data=', data, 'd=', d);
w.focus(); w.focus();
return; return;
} }

View File

@ -19,5 +19,10 @@
<!--- <script src="{{entire_url('/bricks/3parties/videojs-contrib-hls.min.js')}}"></script> ---> <!--- <script src="{{entire_url('/bricks/3parties/videojs-contrib-hls.min.js')}}"></script> --->
<script src="{{entire_url('/bricks/bricks.js')}}"></script> <script src="{{entire_url('/bricks/bricks.js')}}"></script>
<script> <script>
/*
if (bricks.is_mobile()){
alert('wh=' + window.innerWidth + ':' + window.innerHeight);
}
*/
const opts = { const opts = {
"widget": "widget":

View File

@ -507,7 +507,7 @@ bricks.UiText =class extends bricks.UiType {
} }
resultValue(){ resultValue(){
var e = this.dom_element; var e = this.dom_element;
console.log('UiText(), element=', e, 'value=', e.value); bricks.debug('UiText(), element=', e, 'value=', e.value);
this.value = e.value; this.value = e.value;
return this.value; return this.value;
} }
@ -629,11 +629,11 @@ bricks._Input = class {
register(name, Klass){ register(name, Klass){
if (! Klass){ if (! Klass){
console.log('Klass not defined', name); bricks.debug('Klass not defined', name);
return; return;
} }
if (! Klass.uitype){ if (! Klass.uitype){
console.log('uitype of Klass not defined', name); bricks.debug('uitype of Klass not defined', name);
return; return;
} }
@ -645,7 +645,7 @@ bricks._Input = class {
if (klass){ if (klass){
return new klass(options); return new klass(options);
} }
console.log('create input for:', options.uitype, 'failed'); bricks.debug('create input for:', options.uitype, 'failed');
return null; return null;
} }
} }

View File

@ -107,7 +107,7 @@ bricks.HttpText = class {
} }
async withLoginInfo(url, params){ async withLoginInfo(url, params){
var get_login_info = function(e){ var get_login_info = function(e){
console.log('login info:', e.target.getValue()); bricks.debug('login info:', e.target.getValue());
return e.target.getValue(); return e.target.getValue();
} }
var w = await bricks.widgetBuild({ var w = await bricks.widgetBuild({

View File

@ -7,10 +7,10 @@ bricks.Layout = class extends bricks.JsWidget {
} }
add_widget(w, index){ add_widget(w, index){
if (index >=0 && index < this.children.length){ if (index !== null && index >=0 && index < this.children.length){
var pos_w = this.children[index]; var pos_w = this.children[index];
this.dom_element.insertBefore(w.dom_element, pos_w.dom_element); this.dom_element.insertBefore(w.dom_element, pos_w.dom_element);
this.children.insert(index+1, w); this.children.insert(index, w);
} else { } else {
// append child at end // append child at end
w.parent = this; w.parent = this;

View File

@ -23,7 +23,7 @@ bricks.MdText = class extends bricks.JsWidget {
schedule_once(f, 0.01); schedule_once(f, 0.01);
} }
show_scroll(event){ show_scroll(event){
console.log('scrollY=', window.scrollY); bricks.debug('scrollY=', window.scrollY);
} }
build = async function(){ build = async function(){
this._build(this.opts.md_url); this._build(this.opts.md_url);
@ -69,7 +69,7 @@ bricks.MarkdownViewer = class extends bricks.VBox {
this.bind('scroll', this.show_scroll.bind(this)); this.bind('scroll', this.show_scroll.bind(this));
} }
show_scroll(event){ show_scroll(event){
console.log('scrollY=', window.scrollY); bricks.debug('scrollY=', window.scrollY);
} }
createBackButton = async function(){ createBackButton = async function(){
var desc = { var desc = {
@ -85,15 +85,15 @@ bricks.MarkdownViewer = class extends bricks.VBox {
] ]
} }
var w = await bricks.widgetBuild(desc); var w = await bricks.widgetBuild(desc);
console.log('createBackButton():error, desc=', desc, 'w=', w); bricks.debug('createBackButton():error, desc=', desc, 'w=', w);
var t = w.children[0]; var t = w.children[0];
console.log('createBackButton():text=',t); bricks.debug('createBackButton():text=',t);
t.bind('click',this.go_back.bind(this)); t.bind('click',this.go_back.bind(this));
this.add_widget(w); this.add_widget(w);
console.log('createBackButton():desc=',desc, 'w=', w); bricks.debug('createBackButton():desc=',desc, 'w=', w);
} }
add_back_stack(event){ add_back_stack(event){
console.log('go_back_stack():event=', event); bricks.debug('go_back_stack():event=', event);
var url = event.params.url; var url = event.params.url;
this.back_stack.push(url); this.back_stack.push(url);
} }

View File

@ -34,10 +34,10 @@ bricks.Menu = class extends bricks.VBox {
} }
return return
} }
console.log('item clicked'); bricks.debug('item clicked');
} }
create_children(p, items){ create_children(p, items){
console.log('create_children():items=', items, 'p=', p); bricks.debug('create_children():items=', items, 'p=', p);
for (let i=0;i<items.length;i++){ for (let i=0;i<items.length;i++){
let item = items[i]; let item = items[i];
let menu_item = this.create_menuitem(item); let menu_item = this.create_menuitem(item);
@ -51,11 +51,11 @@ bricks.Menu = class extends bricks.VBox {
} }
create_menuitem(item){ create_menuitem(item){
let i18n = bricks.app.i18n; let i18n = bricks.app.i18n;
console.log('i18n=', i18n); bricks.debug('i18n=', i18n);
let e = document.createElement('div'); let e = document.createElement('div');
e.textContent = i18n._(item.label || item.name); e.textContent = i18n._(item.label || item.name);
// e.description = item // e.description = item
console.log('create_menuitem():item=', item, 'obj=', e); bricks.debug('create_menuitem():item=', item, 'obj=', e);
return e; return e;
} }
} }

View File

@ -61,7 +61,7 @@ bricks.MiniForm = class extends bricks.HBox {
this.add_widget(w); this.add_widget(w);
} }
show_options(e){ show_options(e){
console.log('show_options() called ...'); bricks.debug('show_options() called ...');
this.choose.show(); this.choose.show();
} }
change_input(e){ change_input(e){
@ -70,7 +70,7 @@ bricks.MiniForm = class extends bricks.HBox {
} }
input_handle(e){ input_handle(e){
var d = this.getValue(); var d = this.getValue();
console.log('input_handle() ..', d); bricks.debug('input_handle() ..', d);
this.dispatch('input', d); this.dispatch('input', d);
} }
getValue(){ getValue(){

View File

@ -72,7 +72,7 @@ bricks.Modal = class extends bricks.Layout {
if (event.target == this.dom_element){ if (event.target == this.dom_element){
this.dismiss(); this.dismiss();
} else { } else {
console.log('modal():click_handler()'); bricks.debug('modal():click_handler()');
} }
} }
open(){ open(){

View File

@ -1,16 +1,14 @@
var bricks = window.bricks || {}; var bricks = window.bricks || {};
var low_handle = function(widget, dim, last_pos, cur_pos, maxlen, winsize){ var low_handle = function(widget, dim, last_pos, cur_pos, maxlen, winsize){
var dir = cur_pos - last_pos;
var max_rate = cur_pos / (maxlen - winsize); var max_rate = cur_pos / (maxlen - winsize);
var min_rate = cur_pos / maxlen; if (Math.abs(cur_pos + winsize - maxlen) < 1){
if (!widget.threshold && dir > 0 && max_rate >= widget.max_threshold){ bricks.debug('fire max_threshold ......');
widget.thresgold = true;
widget.dispatch('max_threshold'); widget.dispatch('max_threshold');
return return
} }
if (!widget.threshold && dir < 0 && min_rate <= widget.min_threshold){ if (cur_pos < 1) {
widget.thresgold = true; bricks.debug('fire min_threshold ......');
widget.dispatch('min_threshold'); widget.dispatch('min_threshold');
return return
} }
@ -28,20 +26,20 @@ bricks.HScrollPanel = class extends bricks.HBox {
opts.height = '100%'; opts.height = '100%';
opts.overflow = 'auto'; opts.overflow = 'auto';
super(opts); super(opts);
this.min_threshold = opts.min_threshold || 0.02; this.min_threshold = opts.min_threshold || 0.01;
this.max_threshold = opts.max_threshold || 0.95; this.max_threshold = opts.max_threshold || 0.99;
this.bind('scroll', this.scroll_handle.bind(this)) this.bind('scroll', this.scroll_handle.bind(this))
this.last_scrollLeft = this.dom_element.scrollLeft; this.last_scrollLeft = this.dom_element.scrollLeft;
this.threshold = false; this.threshold = false;
} }
scroll_handle(event){ scroll_handle(event){
if (event.target != this.dom_element){ if (event.target != this.dom_element){
// console.log('HScroll():scroll on other', event.target); // bricks.debug('HScroll():scroll on other', event.target);
return; return;
} }
var e = this.dom_element; var e = this.dom_element;
if ( e.scrollWidth - e.clientWidth < 1) { if ( e.scrollWidth - e.clientWidth < 1) {
// console.log('HScroll():same size'); // bricks.debug('HScroll():same size');
return; return;
} }
low_handle(this, 'x', this.last_scrollLeft, low_handle(this, 'x', this.last_scrollLeft,
@ -68,16 +66,16 @@ bricks.VScrollPanel = class extends bricks.VBox {
this.min_threshold = opts.min_threshold || 0.02; this.min_threshold = opts.min_threshold || 0.02;
this.max_threshold = opts.max_threshold || 0.95; this.max_threshold = opts.max_threshold || 0.95;
this.bind('scroll', this.scroll_handle.bind(this)) this.bind('scroll', this.scroll_handle.bind(this))
this.last_scrollTop = this.dom_element.scrollTop; this.last_scrollY = this.dom_element.scrollY;
} }
scroll_handle(event){ scroll_handle(event){
if (event.target != this.dom_element){ if (event.target != this.dom_element){
// console.log('scroll on other', event.target); // bricks.debug('scroll on other', event.target);
return; return;
} }
var e = this.dom_element; var e = this.dom_element;
if ( e.scrollHeight - e.clientHeight < 2) { if ( e.scrollHeight - e.clientHeight < 2) {
// console.log('same size'); // bricks.debug('same size');
return; return;
} }
low_handle(this, 'y', this.last_scrollTop, low_handle(this, 'y', this.last_scrollTop,

View File

@ -82,7 +82,7 @@ bricks.TabPanel = class extends bricks.Layout {
var tdesc = event.params; var tdesc = event.params;
var items = this.opts.items; var items = this.opts.items;
if (tdesc.name == this.cur_tab_name){ if (tdesc.name == this.cur_tab_name){
console.log('TabPanel(): click duplication click on same tab', tdesc) bricks.debug('TabPanel(): click duplication click on same tab', tdesc)
return; return;
} }
for (var i=0;i<items.length;i++){ for (var i=0;i<items.length;i++){
@ -96,7 +96,7 @@ bricks.TabPanel = class extends bricks.Layout {
} }
w = await bricks.widgetBuild(items[i].content); w = await bricks.widgetBuild(items[i].content);
if (! w){ if (! w){
console.log('TabPanel():create content error', items[i].content); bricks.debug('TabPanel():create content error', items[i].content);
return; return;
} }
this.content_buffer[tdesc.name] = w; this.content_buffer[tdesc.name] = w;
@ -106,7 +106,7 @@ bricks.TabPanel = class extends bricks.Layout {
return; return;
} }
} }
console.log('TabPanel(): click event handled but noting to do', tdesc) bricks.debug('TabPanel(): click event handled but noting to do', tdesc)
} }
add_tab(desc){ add_tab(desc){
var item = this.toolbar.createTool(desc); var item = this.toolbar.createTool(desc);

View File

@ -65,7 +65,7 @@ bricks.Toolbar = class extends bricks.Layout {
}; };
var w = await bricks.widgetBuild(options); var w = await bricks.widgetBuild(options);
if (! w){ if (! w){
console.log('Toolbar(): build widget failed', options); bricks.debug('Toolbar(): build widget failed', options);
return return
} }
w.bind('click', this.do_handle.bind(this, w)); w.bind('click', this.do_handle.bind(this, w));
@ -85,7 +85,7 @@ bricks.Toolbar = class extends bricks.Layout {
} }
do_handle(tool, event){ do_handle(tool, event){
// var tool = event.target; // var tool = event.target;
console.log('Toolbar() onclick,target=', event.target, tool); bricks.debug('Toolbar() onclick,target=', event.target, tool);
var d = {}; var d = {};
bricks.extend(d, tool.tool_opts); bricks.extend(d, tool.tool_opts);
if (this.opts.target){ if (this.opts.target){
@ -93,7 +93,7 @@ bricks.Toolbar = class extends bricks.Layout {
} }
this.dispatch('command', d); this.dispatch('command', d);
this.dispatch(tool.tool_opts.name, d); this.dispatch(tool.tool_opts.name, d);
console.log('event ', tool.tool_opts.name, ' fired ...') bricks.debug('event ', tool.tool_opts.name, ' fired ...')
if (this.clicked_btn){ if (this.clicked_btn){
this.clicked_btn.set_css(this.preffix_css + '-button-active', true); this.clicked_btn.set_css(this.preffix_css + '-button-active', true);
} }
@ -107,9 +107,9 @@ bricks.Toolbar = class extends bricks.Layout {
if (image){ if (image){
item.add_widget(image); item.add_widget(image);
image.bind('click',this.remove_item.bind(this, item)); image.bind('click',this.remove_item.bind(this, item));
console.log('Toolbar(): add_removable() for ', img_src); bricks.debug('Toolbar(): add_removable() for ', img_src);
} else { } else {
console.log('Toolbar(): Image create error', img_src); bricks.debug('Toolbar(): Image create error', img_src);
} }
} }
click(name){ click(name){

View File

@ -259,7 +259,7 @@ bricks. EditableTree = class extends bricks.Tree {
this.add_widget(this.toolbar, 0); this.add_widget(this.toolbar, 0);
} }
command_handle(e){ command_handle(e){
console.log('command event fire ...', e); bricks.debug('command event fire ...', e);
var name = e.params.name; var name = e.params.name;
switch (name) { switch (name) {
case 'add': case 'add':
@ -294,7 +294,7 @@ bricks. EditableTree = class extends bricks.Tree {
var n = new bricks.TreeNode(this, node, data); var n = new bricks.TreeNode(this, node, data);
node.container.add_widget(n); node.container.add_widget(n);
n.edit(); n.edit();
console.log('add_node() finished ...'); bricks.debug('add_node() finished ...');
} }
edit_node(){ edit_node(){
if (! this.selected_node){ if (! this.selected_node){

View File

@ -1,5 +1,17 @@
var bricks = window.bricks || {}; var bricks = window.bricks || {};
bricks.isMobile = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); bricks.bug = false;
bricks.debug = function(...args){
if (! bricks.bug){
return;
}
var callInfo;
try {
throw new Error();
} catch (e) {
callInfo = e.stack.split('\n')[2].trim();
}
console.log(callInfo, ...args);
}
bricks.is_mobile = function(){ bricks.is_mobile = function(){
var userAgent = navigator.userAgent; var userAgent = navigator.userAgent;
@ -9,8 +21,10 @@ bricks.is_mobile = function(){
if (('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)) { if (('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)) {
return true; return true;
} }
if (window.innerWidth <= 768 && window.innerHeight <= 1024) {
return true;
}
return false;
} }
class _TypeIcons { class _TypeIcons {
@ -39,7 +53,7 @@ var currentScriptPath = function () {
if (document.currentScript){ if (document.currentScript){
currentScript = document.currentScript.src; currentScript = document.currentScript.src;
} else { } else {
console.log('has not currentScriot'); bricks.debug('has not currentScriot');
var scripts = document.querySelectorAll( 'script[src]' ); var scripts = document.querySelectorAll( 'script[src]' );
if (scripts.length < 1){ if (scripts.length < 1){
return null; return null;
@ -67,7 +81,7 @@ function querySelectorAllShadows(selector, el = document.body) {
const childShadows = Array.from(el.querySelectorAll('*')). const childShadows = Array.from(el.querySelectorAll('*')).
map(el => el.shadowRoot).filter(Boolean); map(el => el.shadowRoot).filter(Boolean);
console.log('[querySelectorAllShadows]', selector, el, `(${childShadows.length} shadowRoots)`); bricks.debug('[querySelectorAllShadows]', selector, el, `(${childShadows.length} shadowRoots)`);
const childResults = childShadows.map(child => querySelectorAllShadows(selector, child)); const childResults = childShadows.map(child => querySelectorAllShadows(selector, child));
@ -93,7 +107,7 @@ var schedule_interval = function(f, t){
} }
var debug = function(){ var debug = function(){
console.log(...arguments); bricks.debug(...arguments);
} }
var import_cache = new Map() var import_cache = new Map()
@ -210,7 +224,7 @@ var archorize = function(ele,archor){
'y':y 'y':y
} }
var tsf = bricks.obj_fmtstr(o, 'translateY(-${y}) translateX(-${x})'); var tsf = bricks.obj_fmtstr(o, 'translateY(-${y}) translateX(-${x})');
console.log('archorize(): tsf=', tsf); bricks.debug('archorize(): tsf=', tsf);
ele.style.transform = tsf; ele.style.transform = tsf;
ele.style.position = "absolute"; ele.style.position = "absolute";
} }
@ -243,7 +257,7 @@ var absurl = function(url, widget){
} }
var debug = function(...args){ var debug = function(...args){
console.log(...args); bricks.debug(...args);
} }
var convert2int = function(s){ var convert2int = function(s){
@ -298,7 +312,7 @@ var objcopy = function(obj){
bricks.playResponseAudio = async function(response, target){ bricks.playResponseAudio = async function(response, target){
var widget = null; var widget = null;
if (response.status != 200){ if (response.status != 200){
console.log('playResponseAudio(): response.status != 200', response.status); bricks.debug('playResponseAudio(): response.status != 200', response.status);
return; return;
} }
if (typeof target == typeof ''){ if (typeof target == typeof ''){
@ -307,7 +321,7 @@ bricks.playResponseAudio = async function(response, target){
widget = bricks.widgetBuild(target); widget = bricks.widgetBuild(target);
} }
if (! widget){ if (! widget){
console.log('playResponseAudio():', target, 'can not found or build a widget'); bricks.debug('playResponseAudio():', target, 'can not found or build a widget');
return; return;
} }
const blob = await response.blob(); const blob = await response.blob();
@ -318,13 +332,13 @@ bricks.playResponseAudio = async function(response, target){
bricks.widgetBuildWithData = async function(desc_tmpl, from_widget, data){ bricks.widgetBuildWithData = async function(desc_tmpl, from_widget, data){
if (!desc_tmpl){ if (!desc_tmpl){
console.log('bricks.widgetBuildWithData():data=', data, 'desc_tmpl=', desc_tmpl); bricks.debug('bricks.widgetBuildWithData():data=', data, 'desc_tmpl=', desc_tmpl);
} }
var s = bricks.obj_fmtstr(data, desc_tmpl); var s = bricks.obj_fmtstr(data, desc_tmpl);
var desc = JSON.parse(s); var desc = JSON.parse(s);
var w = await bricks.widgetBuild(desc, from_widget); var w = await bricks.widgetBuild(desc, from_widget);
if (! w){ if (! w){
console.log(desc, 'widgetBuild() failed...........'); bricks.debug(desc, 'widgetBuild() failed...........');
return; return;
} }
w.row_data = data; w.row_data = data;

View File

@ -40,7 +40,7 @@ bricks.Video = class extends bricks.Layout {
destroy_resource(params, event){ destroy_resource(params, event){
var w = event.target.bricks_widget; var w = event.target.bricks_widget;
if (! w.parent){ if (! w.parent){
console.log('destroy resource .......'); bricks.debug('destroy resource .......');
this.player.pause(); this.player.pause();
this.player.dispose(); this.player.dispose();
this.player = null; this.player = null;
@ -49,7 +49,7 @@ bricks.Video = class extends bricks.Layout {
disable_captions(){ disable_captions(){
this.player.nativeTextTracks = false; this.player.nativeTextTracks = false;
var tt = this.player.textTracks() var tt = this.player.textTracks()
console.log('textTracks=', tt); bricks.debug('textTracks=', tt);
if (tt){ if (tt){
for(var i=0;i<tt.length;i++){ for(var i=0;i<tt.length;i++){
tt[i].mode = 'disabled'; tt[i].mode = 'disabled';

View File

@ -207,6 +207,12 @@ bricks.JsWidget = class {
e.params = params; e.params = params;
this.dom_element.dispatchEvent(e); this.dom_element.dispatchEvent(e);
} }
set_attribute(attr, value){
this.dom_element.setAttribute(attr, value);
}
get_attribute(attr) {
this.dom_element.getAttribute(attr);
}
} }

View File

@ -20,7 +20,7 @@ bricks.Wterm = class extends bricks.JsWidget {
this.term = term; this.term = term;
term.open(this.dom_element); term.open(this.dom_element);
var ws = new WebSocket(this.opts.ws_url); var ws = new WebSocket(this.opts.ws_url);
console.log('FitAddon=', FitAddon); bricks.debug('FitAddon=', FitAddon);
this.fitAddon = new FitAddon.FitAddon() this.fitAddon = new FitAddon.FitAddon()
term.loadAddon(this.fitAddon) term.loadAddon(this.fitAddon)
// this.fitAddon.fit() // this.fitAddon.fit()
@ -44,7 +44,7 @@ bricks.Wterm = class extends bricks.JsWidget {
try { try {
this.fitAddon.fit(); this.fitAddon.fit();
} catch(e){ } catch(e){
console.log('resize error', e); bricks.debug('resize error', e);
} }
} }
} }

View File

@ -2,7 +2,9 @@
{ {
"widgettype":"MarkdownViewer", "widgettype":"MarkdownViewer",
"options":{ "options":{
"width":"100%",
"height":"100%",
"navigator":true, "navigator":true,
"md_url":"../docs/index.md" "md_url":"../docs/README.md"
} }
} }

View File

@ -4,6 +4,7 @@
"options":{ "options":{
"tab_wide":"auto", "tab_wide":"auto",
"height":"100%", "height":"100%",
"width":"100%",
"tab_long":"70%", "tab_long":"70%",
"tab_pos":"top", "tab_pos":"top",
"items":[ "items":[