bugfix
This commit is contained in:
parent
c76c36e57f
commit
a028ba94dc
@ -1,4 +1,5 @@
|
|||||||
class Accordion extends VBox {
|
var bricks = window.bricks || {};
|
||||||
|
bricks.Accordion = class oops extends bricks.VBox {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
item_size:
|
item_size:
|
||||||
@ -69,4 +70,4 @@ class Accordion extends VBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.register('Accordion', Accordion);
|
bricks.Factory.register('Accordion', bricks.Accordion);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
var bricks = window.bricks || {};
|
||||||
class AG_Grid extends JsWidget {
|
bricks.AG_Grid = class oops extends bricks.JsWidget {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
dataurl:
|
dataurl:
|
||||||
|
134
bricks/audio.js
134
bricks/audio.js
@ -1,3 +1,4 @@
|
|||||||
|
var bricks = window.bricks || {};
|
||||||
|
|
||||||
var formatMs=function(ms,all){
|
var formatMs=function(ms,all){
|
||||||
var ss=ms%1000;ms=(ms-ss)/1000;
|
var ss=ms%1000;ms=(ms-ss)/1000;
|
||||||
@ -11,7 +12,7 @@ var formatMs=function(ms,all){
|
|||||||
return t;
|
return t;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AudioPlayer extends JsWidget {
|
bricks.AudioPlayer = class oops extends bricks.JsWidget {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
url:
|
url:
|
||||||
@ -35,7 +36,7 @@ class AudioPlayer extends JsWidget {
|
|||||||
}
|
}
|
||||||
set_source(url){
|
set_source(url){
|
||||||
this.audio.src = url;
|
this.audio.src = url;
|
||||||
console.log(this.source.src,' new src seted');
|
console.log(this.audio.src,' new src seted');
|
||||||
}
|
}
|
||||||
toggle_play(){
|
toggle_play(){
|
||||||
if (this.audio.paused){
|
if (this.audio.paused){
|
||||||
@ -47,45 +48,65 @@ class AudioPlayer extends JsWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.player.source.src = url;
|
bricks.AudioRecorder = class oops extends bricks.HBox {
|
||||||
//webkitURL is deprecated but nevertheless
|
/*
|
||||||
var URL = window.URL || window.webkitURL;
|
events:
|
||||||
var AudioContext = window.AudioContext || window.webkitAudioContext;
|
record_started
|
||||||
|
record_finished wavdata
|
||||||
class AudioRecorder extends HBox {
|
*/
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
super(opts);
|
super(opts);
|
||||||
this.start_icon = opts.start_icon || bricks_resource('imgs/start_recording.png');
|
this.start_icon = opts.start_icon || bricks_resource('imgs/start_recording.png');
|
||||||
this.stop_icon = opts.stop_icon || bricks_resource('imgs/stop_recording.png');
|
this.stop_icon = opts.stop_icon || bricks_resource('imgs/stop_recording.png');
|
||||||
|
this.rec_btn = new bricks.Icon({url:this.start_icon });
|
||||||
|
this.player = new bricks.AudioPlayer({url:"",width:'40px'});
|
||||||
|
this.rec_time = new bricks.Text({text:"", i18n:false, width:'120px'});
|
||||||
|
this.rec_btn.bind('click', this.rec_btn_pressed.bind(this))
|
||||||
|
this.URL = window.URL||webkitURL;
|
||||||
this.rec = null;
|
this.rec = null;
|
||||||
this.wave = null;
|
this.wave = null;
|
||||||
this.recBlob = null;
|
this.mic_opened = false;
|
||||||
this.recOpen();
|
this.add_widget(this.rec_btn);
|
||||||
|
this.add_widget(this.rec_time);
|
||||||
|
this.add_widget(this.player);
|
||||||
|
this.recordData = null;
|
||||||
|
}
|
||||||
|
rec_btn_pressed(){
|
||||||
|
console.log(this.rec_btn.url, ':url:', this.start_icon, this.stop_icon);
|
||||||
|
if(this.rec_btn.url == this.start_icon){
|
||||||
|
this.rec_btn.set_url(this.stop_icon);
|
||||||
|
this.start_recording();
|
||||||
|
} else {
|
||||||
|
this.rec_btn.set_url(this.start_icon);
|
||||||
|
this.stop_recording();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
on_process(buffers,powerLevel,
|
on_process(buffers,powerLevel,
|
||||||
bufferDuration,bufferSampleRate,
|
bufferDuration,bufferSampleRate,
|
||||||
newBufferIdx,asyncEnd){
|
newBufferIdx,asyncEnd){
|
||||||
//录音实时回调,大约1秒调用12次本回调
|
//录音实时回调,大约1秒调用12次本回调
|
||||||
document.querySelector(".recpowerx").style.width=powerLevel+"%";
|
// document.querySelector(".recpowerx").style.width=powerLevel+"%";
|
||||||
document.querySelector(".recpowert").innerText=formatMs(bufferDuration,1)+" / "+powerLevel;
|
|
||||||
|
|
||||||
//可视化图形绘制
|
//可视化图形绘制
|
||||||
wave.input(buffers[buffers.length-1],powerLevel,bufferSampleRate);
|
// wave.input(buffers[buffers.length-1],powerLevel,bufferSampleRate);
|
||||||
|
this.rec_time.otext = formatMs(bufferDuration,1);
|
||||||
|
console.log(this.rec_time.otext);
|
||||||
|
|
||||||
}
|
}
|
||||||
recOpen(){
|
recOpen(){
|
||||||
this.rec=null;
|
this.rec=null;
|
||||||
this.wave=null;
|
this.wave=null;
|
||||||
this.recBlob=null;
|
var newRec = Recorder({
|
||||||
var newRec=Recorder({
|
|
||||||
type:"wav",sampleRate:16000,bitRate:16
|
type:"wav",sampleRate:16000,bitRate:16
|
||||||
,onProcess:this.on_process.bind(this)
|
,onProcess:this.on_process.bind(this)
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
newRec.open(function(){//打开麦克风授权获得相关资源
|
newRec.open(function(){//打开麦克风授权获得相关资源
|
||||||
|
this.mic_opened = true;
|
||||||
this.rec=newRec;
|
this.rec=newRec;
|
||||||
|
this.rec.start();
|
||||||
|
this.dispatch('record_started');
|
||||||
//此处创建这些音频可视化图形绘制浏览器支持妥妥的
|
//此处创建这些音频可视化图形绘制浏览器支持妥妥的
|
||||||
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');
|
console.log('open recorder failed');
|
||||||
});
|
});
|
||||||
@ -97,13 +118,19 @@ class AudioRecorder extends HBox {
|
|||||||
console.log('close recorder error');
|
console.log('close recorder error');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
recoding(){
|
||||||
|
this.n
|
||||||
|
}
|
||||||
start_recording(){
|
start_recording(){
|
||||||
if(this.rec&&Recorder.IsOpen()){
|
this.recordData = null;
|
||||||
this.recBlob=null;
|
if( this.recordData ){
|
||||||
|
this.URL.revokeObjectURL(this.recordData.url);
|
||||||
|
}
|
||||||
|
if (this.mic_opened){
|
||||||
this.rec.start();
|
this.rec.start();
|
||||||
}else{
|
this.dispatch('record_started');
|
||||||
console.log("ajKR::未打开录音");
|
}
|
||||||
};
|
this.recOpen();
|
||||||
}
|
}
|
||||||
pause_recording(){
|
pause_recording(){
|
||||||
if(this.rec&&Recorder.IsOpen()){
|
if(this.rec&&Recorder.IsOpen()){
|
||||||
@ -125,63 +152,48 @@ class AudioRecorder extends HBox {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
this.rec.stop(function(blob,duration){
|
this.rec.stop(function(blob,duration){
|
||||||
console.log(blob,(window.URL||webkitURL).createObjectURL(blob),Html_xT(Html_$T("gOix::时长:{1}ms",0,duration)));
|
var localURL = this.URL.createObjectURL(blob);
|
||||||
|
var d = {
|
||||||
this.recBlob=blob;
|
data:blob,
|
||||||
console.log("0LHf::已录制mp3:{1}ms {2}字节,可以点击播放、上传、本地下载了",0,formatMs(duration),blob.size);
|
url:localURL,
|
||||||
|
duration:duration
|
||||||
|
}
|
||||||
|
this.recordData = d;
|
||||||
|
this.player.set_source(this.recordData.url);
|
||||||
|
this.dispatch('record_finished', d);
|
||||||
|
|
||||||
}.bind(this),function(msg){
|
}.bind(this),function(msg){
|
||||||
console.log("kGZO::录音失败:");
|
console.log("kGZO::录音失败:");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
play_record(){
|
async upload(){
|
||||||
if(!this.recBlob){
|
if(!this.recordData){
|
||||||
console.log("tIke::请先录音,然后停止后再播放");
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
var cls=("a"+Math.random()).replace(".","");
|
|
||||||
var audio=document.createElement("audio");
|
|
||||||
audio.controls=true;
|
|
||||||
document.querySelector("."+cls).appendChild(audio);
|
|
||||||
//简单利用URL生成播放地址,注意不用了时需要revokeObjectURL,否则霸占内存
|
|
||||||
audio.src=(window.URL||webkitURL).createObjectURL(recBlob);
|
|
||||||
audio.play();
|
|
||||||
|
|
||||||
setTimeout(function(){
|
|
||||||
(window.URL||webkitURL).revokeObjectURL(audio.src);
|
|
||||||
},5000);
|
|
||||||
}
|
|
||||||
upload(){
|
|
||||||
var blob=this.recBlob;
|
|
||||||
if(!blob){
|
|
||||||
console.log("DUTn::请先录音,然后停止后再上传");
|
console.log("DUTn::请先录音,然后停止后再上传");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
var blob=this.recordData.blob;
|
||||||
var form=new FormData();
|
var form=new FormData();
|
||||||
form.append("audiofile",blob,"recorder.wav");
|
form.append("audiofile",blob,"recorder.wav");
|
||||||
const data = new URLSearchParams();
|
var hj = HttpJson()
|
||||||
for (const pair of form)) {
|
var ret = await hj.post(this.upload_url,{
|
||||||
data.append(pair[0], pair[1]);
|
params:form
|
||||||
}
|
|
||||||
hj = HttpJson()
|
|
||||||
ret = await hj.post(this.upload_url,{
|
|
||||||
params:data
|
|
||||||
});
|
});
|
||||||
console.log('ret=', ret);
|
console.log('ret=', ret);
|
||||||
this.dispatch('updated', ret)
|
this.dispatch('updated', ret)
|
||||||
}
|
}
|
||||||
download(){
|
download(){
|
||||||
if(!this.recBlob){
|
if(!this.recordData){
|
||||||
console.log('recorder not opened');
|
console.log('recorder not opened');
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
var fileName="recorder-"+Date.now()+".wav";
|
var fileName="recorder-"+Date.now()+".wav";
|
||||||
var downA=document.createElement("A");
|
var downA=document.createElement("A");
|
||||||
downA.innerHTML="下载")+fileName;
|
downA.innerHTML="下载"+fileName;
|
||||||
downA.href=(window.URL||webkitURL).createObjectURL(this.recBlob);
|
downA.href=this.recordData.url;
|
||||||
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');
|
||||||
}
|
}
|
||||||
downA.click();
|
downA.click();
|
||||||
//不用了时需要revokeObjectURL,否则霸占内存
|
//不用了时需要revokeObjectURL,否则霸占内存
|
||||||
@ -189,5 +201,5 @@ class AudioRecorder extends HBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.register('AudioPlayer', AudioPlayer);
|
bricks.Factory.register('AudioPlayer', bricks.AudioPlayer);
|
||||||
Factory.register('AudioRecorder', AudioRecorder);
|
bricks.Factory.register('AudioRecorder', bricks.AudioRecorder);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
var bricks = window.bricks || {};
|
||||||
|
|
||||||
var tooltip = null;
|
var tooltip = null;
|
||||||
|
|
||||||
createTooltip = function(){
|
bricks.createTooltip = function(){
|
||||||
tooltip = document.createElement('div');
|
tooltip = document.createElement('div');
|
||||||
tooltip.className = 'tooltip';
|
tooltip.className = 'tooltip';
|
||||||
tooltip.style.left = '50%';
|
tooltip.style.left = '50%';
|
||||||
@ -19,7 +21,7 @@ createTooltip = function(){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let bricks_app = null;
|
bricks.app = null;
|
||||||
/*
|
/*
|
||||||
all type of bind action's desc has the following attributes:
|
all type of bind action's desc has the following attributes:
|
||||||
actiontype:'bricks',
|
actiontype:'bricks',
|
||||||
@ -67,9 +69,9 @@ dispatch_event:
|
|||||||
params:
|
params:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var widgetBuild = async function(desc, widget){
|
bricks.widgetBuild = async function(desc, widget){
|
||||||
if (! widget){
|
if (! widget){
|
||||||
widget = Body;
|
widget = bricks.Body;
|
||||||
}
|
}
|
||||||
const klassname = desc.widgettype;
|
const klassname = desc.widgettype;
|
||||||
var base_url = null;
|
var base_url = null;
|
||||||
@ -82,9 +84,9 @@ var widgetBuild = async function(desc, widget){
|
|||||||
} else {
|
} else {
|
||||||
base_url = widget.baseURI;
|
base_url = widget.baseURI;
|
||||||
}
|
}
|
||||||
let klass = Factory.get(desc.widgettype);
|
let klass = bricks.Factory.get(desc.widgettype);
|
||||||
if (! klass){
|
if (! klass){
|
||||||
console.log('widgetBuild():',desc.widgettype, 'not registered', Factory.widgets_kw);
|
console.log('widgetBuild():',desc.widgettype, 'not registered', bricks.Factory.widgets_kw);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
desc.options.baseURI = base_url;
|
desc.options.baseURI = base_url;
|
||||||
@ -95,7 +97,7 @@ var widgetBuild = async function(desc, widget){
|
|||||||
if (desc.hasOwnProperty('subwidgets')){
|
if (desc.hasOwnProperty('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 widgetBuild(sdesc, w);
|
let sw = await (bricks.widgetBuild(sdesc, w));
|
||||||
if ( sw ){
|
if ( sw ){
|
||||||
w.add_widget(sw);
|
w.add_widget(sw);
|
||||||
} else {
|
} else {
|
||||||
@ -105,14 +107,14 @@ var widgetBuild = async function(desc, widget){
|
|||||||
}
|
}
|
||||||
if (desc.hasOwnProperty('binds')){
|
if (desc.hasOwnProperty('binds')){
|
||||||
for (var i=0;i<desc.binds.length; i++){
|
for (var i=0;i<desc.binds.length; i++){
|
||||||
buildBind(w, desc.binds[i]);
|
bricks.buildBind(w, desc.binds[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
var buildBind = function(w, desc){
|
bricks.buildBind = function(w, desc){
|
||||||
var widget = getWidgetById(desc.wid, w);
|
var widget = bricks.getWidgetById(desc.wid, w);
|
||||||
if (!widget){
|
if (!widget){
|
||||||
cnsole.log('desc wid not find', desc);
|
cnsole.log('desc wid not find', desc);
|
||||||
return;
|
return;
|
||||||
@ -121,10 +123,10 @@ var buildBind = function(w, desc){
|
|||||||
buildEventBind(w, widget, event, desc);
|
buildEventBind(w, widget, event, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
var buildEventBind = function(from_widget, widget, event, desc){
|
bricks.buildEventBind = function(from_widget, widget, event, desc){
|
||||||
var handler = universal_handler.bind(null,from_widget, widget, desc);
|
var handler = bricks.universal_handler.bind(null,from_widget, widget, desc);
|
||||||
if (desc.conform){
|
if (desc.conform){
|
||||||
var conform_widget = widgetBuild(desc.conform, widget);
|
var conform_widget = await (bricks.widgetBuild(desc.conform, widget));
|
||||||
conform_widget.bind('on_conform', handler);
|
conform_widget.bind('on_conform', handler);
|
||||||
handler = conform_widget.open.bind(conform_widget);
|
handler = conform_widget.open.bind(conform_widget);
|
||||||
}
|
}
|
||||||
@ -132,13 +134,13 @@ var buildEventBind = function(from_widget, widget, event, desc){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var universal_handler = function(from_widget, widget, desc, event){
|
bricks.universal_handler = function(from_widget, widget, desc, event){
|
||||||
debug('universal_handler() info', 'from_widget=',
|
debug('universal_handler() info', 'from_widget=',
|
||||||
from_widget,
|
from_widget,
|
||||||
'widget=', widget,
|
'widget=', widget,
|
||||||
'desc=', desc,
|
'desc=', desc,
|
||||||
event);
|
event);
|
||||||
var f = buildEventHandler(from_widget, desc);
|
var f = bricks.buildEventHandler(from_widget, desc);
|
||||||
if (f){
|
if (f){
|
||||||
return f(event);
|
return f(event);
|
||||||
}
|
}
|
||||||
@ -148,8 +150,8 @@ var universal_handler = function(from_widget, widget, desc, event){
|
|||||||
'desc=', desc,
|
'desc=', desc,
|
||||||
event);
|
event);
|
||||||
}
|
}
|
||||||
var buildEventHandler = function(w, desc){
|
bricks.buildEventHandler = function(w, desc){
|
||||||
var target = getWidgetById(desc.target, w);
|
var target = bricks.getWidgetById(desc.target, w);
|
||||||
if (! target){
|
if (! target){
|
||||||
console.log('target miss desc=', desc, 'w=', w);
|
console.log('target miss desc=', desc, 'w=', w);
|
||||||
return null
|
return null
|
||||||
@ -163,35 +165,35 @@ var buildEventHandler = function(w, desc){
|
|||||||
params:desc.dataparams,
|
params:desc.dataparams,
|
||||||
script:desc.datascript
|
script:desc.datascript
|
||||||
}
|
}
|
||||||
rtdata = getRealtimeData(w, data_desc);
|
rtdata = bricks.getRealtimeData(w, data_desc);
|
||||||
}
|
}
|
||||||
switch (desc.actiontype){
|
switch (desc.actiontype){
|
||||||
case 'urlwidget':
|
case 'urlwidget':
|
||||||
return buildUrlwidgetHandler(w, target, rtdata, desc);
|
return bricks.buildUrlwidgetHandler(w, target, rtdata, desc);
|
||||||
break;
|
break;
|
||||||
case 'bricks':
|
case 'bricks':
|
||||||
return buildBricksHandler(w, target, rtdata, desc);
|
return bricks.buildBricksHandler(w, target, rtdata, desc);
|
||||||
break;
|
break;
|
||||||
case 'registerfunction':
|
case 'registerfunction':
|
||||||
return buildRegisterFunction(w, target, rtdata, desc);
|
return bricks.buildRegisterFunction(w, target, rtdata, desc);
|
||||||
break;
|
break;
|
||||||
case 'method':
|
case 'method':
|
||||||
return buildMethodHandler(w, target, rtdata, desc);
|
return bricks.buildMethodHandler(w, target, rtdata, desc);
|
||||||
break;
|
break;
|
||||||
case 'script':
|
case 'script':
|
||||||
var f = buildScriptHandler(w, target, rtdata, desc);
|
var f = bricks.buildScriptHandler(w, target, rtdata, desc);
|
||||||
return f;
|
return f;
|
||||||
break;
|
break;
|
||||||
case 'event':
|
case 'event':
|
||||||
return buildDispatchEventHandler(w, target, rtdata, desc);
|
return bricks.buildDispatchEventHandler(w, target, rtdata, desc);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log('invalid actiontype', target, desc);
|
console.log('invalid actiontype', target, desc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var getRealtimeData = function(w, desc){
|
bricks.getRealtimeData = function(w, desc){
|
||||||
var target = getWidgetById(desc.widget, w);
|
var target = bricks.getWidgetById(desc.widget, w);
|
||||||
var f;
|
var f;
|
||||||
if (! target){
|
if (! target){
|
||||||
console.log('target miss', desc);
|
console.log('target miss', desc);
|
||||||
@ -209,10 +211,10 @@ var getRealtimeData = function(w, desc){
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var 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);
|
||||||
var w = await widgetBuild(options, w);
|
var w = await (bricks.widgetBuild(options, w));
|
||||||
if (!w){
|
if (!w){
|
||||||
console.log('options=', options, 'widgetBuild() failed');
|
console.log('options=', options, 'widgetBuild() failed');
|
||||||
return;
|
return;
|
||||||
@ -230,10 +232,10 @@ var buildUrlwidgetHandler = function(w, target, rtdata, desc){
|
|||||||
}
|
}
|
||||||
return f.bind(target, target, desc.mode || 'replace', opts);
|
return f.bind(target, target, desc.mode || 'replace', opts);
|
||||||
}
|
}
|
||||||
var 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);
|
console.log('target=', target, 'mode=', mode, 'options=', options);
|
||||||
var w = await widgetBuild(options, w);
|
var w = await (bricks.widgetBuild(options, wa));
|
||||||
if (!w){
|
if (!w){
|
||||||
console.log('options=', options, 'widgetBuild() failed');
|
console.log('options=', options, 'widgetBuild() failed');
|
||||||
return;
|
return;
|
||||||
@ -247,7 +249,7 @@ var buildBricksHandler = function(w, target, rtdata, desc){
|
|||||||
extend(options.options, rtdata);
|
extend(options.options, rtdata);
|
||||||
return f.bind(target, target, desc.mode || 'replace', options);
|
return f.bind(target, target, desc.mode || 'replace', options);
|
||||||
}
|
}
|
||||||
var 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);
|
console.log('rfname:', desc.rfname, 'not registed', desc);
|
||||||
@ -262,7 +264,7 @@ var buildRegisterFunctionHandler = function(w, target, rtdata, desc){
|
|||||||
}
|
}
|
||||||
return f.bind(target, params);
|
return f.bind(target, params);
|
||||||
}
|
}
|
||||||
var 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('method:', desc.method, 'not exists in', target, 'w=', w);
|
||||||
@ -273,7 +275,7 @@ var buildMethodHandler = function(w, target, rtdata, desc){
|
|||||||
extend(params, rtdata);
|
extend(params, rtdata);
|
||||||
return f.bind(target, params);
|
return f.bind(target, params);
|
||||||
}
|
}
|
||||||
var buildScriptHandler = function(w, target, rtdata, desc){
|
bricks.buildScriptHandler = function(w, target, rtdata, desc){
|
||||||
var params = {};
|
var params = {};
|
||||||
extend(params, desc.params)
|
extend(params, desc.params)
|
||||||
extend(params, rtdata);
|
extend(params, rtdata);
|
||||||
@ -281,7 +283,7 @@ var buildScriptHandler = function(w, target, rtdata, desc){
|
|||||||
console.log('params=', params, 'buildScriptHandler() ..........');
|
console.log('params=', params, 'buildScriptHandler() ..........');
|
||||||
return f.bind(target, target, params);
|
return f.bind(target, target, params);
|
||||||
}
|
}
|
||||||
var buildDispatchEventHandler = function(w, target, rtdata, desc){
|
bricks.buildDispatchEventHandler = function(w, target, rtdata, desc){
|
||||||
var params = {};
|
var params = {};
|
||||||
extend(params, desc.params)
|
extend(params, desc.params)
|
||||||
extend(params, rtdata);
|
extend(params, rtdata);
|
||||||
@ -291,7 +293,7 @@ var buildDispatchEventHandler = function(w, target, rtdata, desc){
|
|||||||
return f.bind(target, params);
|
return f.bind(target, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
var getWidgetById = function(id, from_widget){
|
bricks.getWidgetById = function(id, from_widget){
|
||||||
if (! id){
|
if (! id){
|
||||||
return from_widget;
|
return from_widget;
|
||||||
}
|
}
|
||||||
@ -307,14 +309,14 @@ var getWidgetById = function(id, from_widget){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ids[i]=='root'){
|
if (ids[i]=='root'){
|
||||||
el = bricks_app.root.dom_element;
|
el = bricks.app.root.dom_element;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ids[i]=='app'){
|
if (ids[i]=='app'){
|
||||||
return bricks_app;
|
return bricks.app;
|
||||||
}
|
}
|
||||||
if (ids[i] == 'window'){
|
if (ids[i] == 'window'){
|
||||||
el = Body.dom_element;
|
el = bricks.Body.dom_element;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +346,7 @@ var getWidgetById = function(id, from_widget){
|
|||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
class BricksApp {
|
bricks.App = class {
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
/*
|
/*
|
||||||
opts = {
|
opts = {
|
||||||
@ -363,7 +365,7 @@ class BricksApp {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
this.opts = opts;
|
this.opts = opts;
|
||||||
bricks_app = this;
|
bricks.app = this;
|
||||||
this.login_url = opts.login_url;
|
this.login_url = opts.login_url;
|
||||||
this.charsize = this.opts.charsize || 20;
|
this.charsize = this.opts.charsize || 20;
|
||||||
if (this.opts.language){
|
if (this.opts.language){
|
||||||
@ -375,7 +377,7 @@ class BricksApp {
|
|||||||
this.textList = [];
|
this.textList = [];
|
||||||
this.i18n = new I18n(objget(opts, 'i18n', {}));
|
this.i18n = new I18n(objget(opts, 'i18n', {}));
|
||||||
this.session_id = null;
|
this.session_id = null;
|
||||||
createTooltip();
|
bricks.createTooltip();
|
||||||
}
|
}
|
||||||
save_session(session){
|
save_session(session){
|
||||||
this.session_id = session;
|
this.session_id = session;
|
||||||
@ -416,22 +418,21 @@ class BricksApp {
|
|||||||
}
|
}
|
||||||
async build(){
|
async build(){
|
||||||
var opts = structuredClone(this.opts.widget);
|
var opts = structuredClone(this.opts.widget);
|
||||||
var w = await widgetBuild(opts, Body);
|
var w = await (bricks.widgetBuild(opts, bricks.Body));
|
||||||
if (!w){
|
if (!w){
|
||||||
console.log('build() end', this.opts.widget, w, 'body=', Body);
|
console.log('w=', w, 'Body=', bricks.Body, 'Factory=', bricks.Factory)
|
||||||
console.log('w=', w, 'Body=', Body, Wterm, 'Factory=', Factory)
|
|
||||||
}
|
}
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
async run(){
|
async run(){
|
||||||
await this.change_language(this);
|
await (this.change_language(this));
|
||||||
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=', Body, Wterm, 'Factory=', Factory)
|
console.log('w=', w, 'Body=', bricks.Body, 'Factory=', bricks.Factory)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Body.add_widget(w);
|
bricks.Body.add_widget(w);
|
||||||
}
|
}
|
||||||
textsize_bigger(){
|
textsize_bigger(){
|
||||||
this.charsize = this.charsize * 1.05;
|
this.charsize = this.charsize * 1.05;
|
||||||
@ -452,7 +453,7 @@ class BricksApp {
|
|||||||
}
|
}
|
||||||
change_language = async function(lang){
|
change_language = async function(lang){
|
||||||
this.lang = lang;
|
this.lang = lang;
|
||||||
await this.i18n.change_lang(lang);
|
await (this.i18n.change_lang(lang));
|
||||||
for (var i=0;i<this.textList.length;i++){
|
for (var i=0;i<this.textList.length;i++){
|
||||||
if(this.textList[i].deref()){
|
if(this.textList[i].deref()){
|
||||||
var w = this.textList[i].deref();
|
var w = this.textList[i].deref();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
SOURCES="uitypesdef.js utils.js i18n.js factory.js widget.js \
|
SOURCES=" factory.js uitypesdef.js utils.js i18n.js widget.js \
|
||||||
bricks.js image.js recorder.js \
|
bricks.js image.js \
|
||||||
jsoncall.js myoperator.js layout.js menu.js modal.js \
|
jsoncall.js myoperator.js layout.js menu.js modal.js \
|
||||||
markdown_viewer.js video.js audio.js toolbar.js tab.js \
|
markdown_viewer.js video.js audio.js toolbar.js tab.js \
|
||||||
input.js registerfunction.js button.js accordion.js \
|
input.js registerfunction.js button.js accordion.js \
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
class Button extends Layout {
|
bricks.Button = class extends bricks.Layout {
|
||||||
/*
|
/*
|
||||||
orientation:
|
orientation:
|
||||||
height:100%,
|
height:100%,
|
||||||
@ -56,7 +56,7 @@ class Button extends Layout {
|
|||||||
this.dom_element = document.createElement('button');
|
this.dom_element = document.createElement('button');
|
||||||
}
|
}
|
||||||
opts_setup(){
|
opts_setup(){
|
||||||
var item_size = this.opts.item_size || bricks_app.charsize;
|
var item_size = this.opts.item_size || bricks.app.charsize;
|
||||||
if (this.opts.icon){
|
if (this.opts.icon){
|
||||||
var icon = new Icon({
|
var icon = new Icon({
|
||||||
rate:this.item_rate,
|
rate:this.item_rate,
|
||||||
@ -89,4 +89,4 @@ class Button extends Layout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.register('Button', Button);
|
bricks.Factory.register('Button', bricks.Button);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
class Row {
|
bricks = window.bricks || {};
|
||||||
|
bricks.Row = class {
|
||||||
constructor(dg, rec) {
|
constructor(dg, rec) {
|
||||||
this.dg = dg;
|
this.dg = dg;
|
||||||
this.data = objcopy(rec);
|
this.data = objcopy(rec);
|
||||||
@ -89,7 +90,7 @@ class Row {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DataGrid extends VBox {
|
bricks.DataGrid = class extends bricks.VBox {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
data:
|
data:
|
||||||
@ -231,7 +232,7 @@ class DataGrid extends VBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_row(data, index) {
|
add_row(data, index) {
|
||||||
var row = new Row(this, data);
|
var row = new bricks.Row(this, data);
|
||||||
if (this.freeze_body)
|
if (this.freeze_body)
|
||||||
this.freeze_body.add_widget(row.freeze_row, index);
|
this.freeze_body.add_widget(row.freeze_row, index);
|
||||||
if (this.normal_body)
|
if (this.normal_body)
|
||||||
@ -381,4 +382,4 @@ class DataGrid extends VBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.register('DataGrid', DataGrid);
|
bricks.Factory.register('DataGrid', bricks.DataGrid);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
bricks = window.bricks || {};
|
||||||
|
|
||||||
class DataViewer extends VScrollPanel {
|
bricks.DataViewer = class extends bricks.VScrollPanel {
|
||||||
/*
|
/*
|
||||||
opts={
|
opts={
|
||||||
dataurl:
|
dataurl:
|
||||||
@ -67,4 +68,4 @@ class DataViewer extends VScrollPanel {
|
|||||||
this.add_widget(w, index);
|
this.add_widget(w, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Factory.register('DataViewer', DataViewer);
|
bricks.Factory.register('DataViewer', bricks.DataViewer);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
bricks = window.bricks || {};
|
||||||
class Factory_ {
|
class Factory_ {
|
||||||
constructor(){
|
constructor(){
|
||||||
this.widgets_kv = new Object();
|
this.widgets_kv = new Object();
|
||||||
@ -13,5 +14,5 @@ class Factory_ {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const Factory = new Factory_();
|
bricks.Factory = new Factory_();
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
};
|
};
|
||||||
const app = new BricksApp(opts);
|
const app = new bricks.App(opts);
|
||||||
app.run();
|
app.run();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
bricks = window.bricks || {};
|
||||||
|
|
||||||
class FormBody extends VBox {
|
bricks.FormBody = class extends bricks.VBox {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
title:
|
title:
|
||||||
@ -102,7 +103,7 @@ class FormBody extends VBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class Form extends VBox {
|
bricks.Form = class extends bricks.VBox {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
title:
|
title:
|
||||||
@ -175,7 +176,7 @@ class Form extends VBox {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class TabForm extends Form {
|
bricks.TabForm = class extends bricks.Form {
|
||||||
/*
|
/*
|
||||||
options
|
options
|
||||||
{
|
{
|
||||||
@ -209,5 +210,5 @@ class TabForm extends Form {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.register('Form', Form);
|
bricks.Factory.register('Form', bricks.Form);
|
||||||
// Factory.register('TabForm', TabForm);
|
// Factory.register('TabForm', TabForm);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
class Image extends JsWidget {
|
var bricks = window.bricks || {};
|
||||||
|
bricks.Image = class oops extends bricks.JsWidget {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
url:
|
url:
|
||||||
@ -33,22 +34,22 @@ class Image extends JsWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Icon extends Image {
|
bricks.Icon = class oops extends bricks.Image {
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
super(opts);
|
super(opts);
|
||||||
this.opts.width = bricks_app.charsize;
|
this.opts.width = bricks.app.charsize;
|
||||||
this.opts.height = bricks_app.charsize;
|
this.opts.height = bricks.app.charsize;
|
||||||
this.ctype = 'text';
|
this.ctype = 'text';
|
||||||
this.sizable();
|
this.sizable();
|
||||||
this.set_fontsize();
|
this.set_fontsize();
|
||||||
}
|
}
|
||||||
change_fontsize(ts){
|
change_fontsize(ts){
|
||||||
var siz = bricks_app.charsize;
|
var siz = bricks.app.charsize;
|
||||||
this.set_width(siz);
|
this.set_width(siz);
|
||||||
this.set_height(siz);
|
this.set_height(siz);
|
||||||
}
|
}
|
||||||
set_fontsize(){
|
set_fontsize(){
|
||||||
var siz = bricks_app.charsize;
|
var siz = bricks.app.charsize;
|
||||||
this.set_width(siz);
|
this.set_width(siz);
|
||||||
this.set_height(siz);
|
this.set_height(siz);
|
||||||
}
|
}
|
||||||
@ -60,22 +61,22 @@ class Icon extends Image {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BlankIcon extends JsWidget {
|
bricks.BlankIcon = class oops extends bricks.JsWidget {
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
opts.width = bricks_app.charsize;
|
opts.width = bricks.app.charsize;
|
||||||
opts.height = bricks_app.charsize;
|
opts.height = bricks.app.charsize;
|
||||||
super(opts);
|
super(opts);
|
||||||
this.ctype = 'text';
|
this.ctype = 'text';
|
||||||
this.sizable();
|
this.sizable();
|
||||||
this.set_fontsize();
|
this.set_fontsize();
|
||||||
}
|
}
|
||||||
change_fontsize(ts){
|
change_fontsize(ts){
|
||||||
var siz = bricks_app.charsize + 'px';
|
var siz = bricks.app.charsize + 'px';
|
||||||
this.set_width(siz);
|
this.set_width(siz);
|
||||||
this.set_height(siz);
|
this.set_height(siz);
|
||||||
}
|
}
|
||||||
set_fontsize(){
|
set_fontsize(){
|
||||||
var siz = bricks_app.charsize + 'px';
|
var siz = bricks.app.charsize + 'px';
|
||||||
this.set_width(siz);
|
this.set_width(siz);
|
||||||
this.set_height(siz);
|
this.set_height(siz);
|
||||||
}
|
}
|
||||||
@ -89,6 +90,6 @@ class BlankIcon extends JsWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.register('Image', Image);
|
bricks.Factory.register('Image', bricks.Image);
|
||||||
Factory.register('Icon', Icon);
|
bricks.Factory.register('Icon', bricks.Icon);
|
||||||
Factory.register('BlankIcon', BlankIcon);
|
bricks.Factory.register('BlankIcon', bricks.BlankIcon);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
class UiType extends Layout {
|
bricks = window.bricks || {};
|
||||||
|
bricks.UiType =class extends bricks.Layout {
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
super(opts);
|
super(opts);
|
||||||
this.name = this.opts.name;
|
this.name = this.opts.name;
|
||||||
@ -38,7 +39,7 @@ class UiType extends Layout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UiStr extends UiType {
|
bricks.UiStr =class extends bricks.UiType {
|
||||||
static uitype='str';
|
static uitype='str';
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@ -94,7 +95,7 @@ class UiStr extends UiType {
|
|||||||
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('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))
|
||||||
@ -143,7 +144,7 @@ class UiStr extends UiType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UiPassword extends UiStr {
|
bricks.UiPassword =class extends bricks.UiStr {
|
||||||
static uitype='password';
|
static uitype='password';
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@ -163,7 +164,7 @@ class UiPassword extends UiStr {
|
|||||||
this.dom_element.type = 'password';
|
this.dom_element.type = 'password';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class UiInt extends UiStr {
|
bricks.UiInt =class extends bricks.UiStr {
|
||||||
static uitype='int';
|
static uitype='int';
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@ -187,7 +188,7 @@ class UiInt extends UiStr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
class UiFloat extends UiInt {
|
bricks.UiFloat =class extends bricks.UiInt {
|
||||||
static uitype='float';
|
static uitype='float';
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@ -213,7 +214,7 @@ class UiFloat extends UiInt {
|
|||||||
this.dom_element.value = '' + v;
|
this.dom_element.value = '' + v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class UiTel extends UiStr {
|
bricks.UiTel =class extends bricks.UiStr {
|
||||||
static uitype='tel';
|
static uitype='tel';
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@ -230,7 +231,7 @@ class UiTel extends UiStr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UiEmail extends UiStr {
|
bricks.UiEmail =class extends bricks.UiStr {
|
||||||
static uitype='email';
|
static uitype='email';
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@ -246,7 +247,7 @@ class UiEmail extends UiStr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UiFile extends UiStr {
|
bricks.UiFile =class extends bricks.UiStr {
|
||||||
static uitype='file';
|
static uitype='file';
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@ -272,7 +273,7 @@ class UiFile extends UiStr {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class UiCheck extends UiType {
|
bricks.UiCheck =class extends bricks.UiType {
|
||||||
static uitype = 'check';
|
static uitype = 'check';
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
super(opts);
|
super(opts);
|
||||||
@ -319,7 +320,7 @@ class UiCheck extends UiType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UiCheckBox extends UiType {
|
bricks.UiCheckBox =class extends bricks.UiType {
|
||||||
static uitype='checkbox';
|
static uitype='checkbox';
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@ -353,7 +354,7 @@ class UiCheckBox extends UiType {
|
|||||||
this.set_fontsize();
|
this.set_fontsize();
|
||||||
this.el_legend = this._create('legend');
|
this.el_legend = this._create('legend');
|
||||||
var label = this.opts.label||this.opts.name;
|
var label = this.opts.label||this.opts.name;
|
||||||
this.el_legend.innerText = bricks_app.i18n._(label);
|
this.el_legend.innerText = bricks.app.i18n._(label);
|
||||||
if (this.opts.dataurl){
|
if (this.opts.dataurl){
|
||||||
schedule_once(this.load_data_onfly.bind(this), 0.01);
|
schedule_once(this.load_data_onfly.bind(this), 0.01);
|
||||||
} else {
|
} else {
|
||||||
@ -426,7 +427,7 @@ class UiCheckBox extends UiType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UiDate extends UiStr {
|
bricks.UiDate =class extends bricks.UiStr {
|
||||||
static uitype='date';
|
static uitype='date';
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@ -450,7 +451,7 @@ class UiDate extends UiStr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UiText extends UiType {
|
bricks.UiText =class extends bricks.UiType {
|
||||||
static uitype='text';
|
static uitype='text';
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@ -501,7 +502,7 @@ class UiText extends UiType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UiCode extends UiType {
|
bricks.UiCode =class extends bricks.UiType {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
name:
|
name:
|
||||||
@ -557,7 +558,7 @@ class UiCode extends UiType {
|
|||||||
for (var i=0; i<data.length; i++){
|
for (var i=0; i<data.length; i++){
|
||||||
var o = document.createElement('option');
|
var o = document.createElement('option');
|
||||||
o.value = data[i][this.opts.valueField||'value'];
|
o.value = data[i][this.opts.valueField||'value'];
|
||||||
o.innerText = bricks_app.i18n._(data[i][this.opts.textField||'text']);
|
o.innerText = bricks.app.i18n._(data[i][this.opts.textField||'text']);
|
||||||
this.option_widgets[o.value] = o;
|
this.option_widgets[o.value] = o;
|
||||||
if (o.value == v){
|
if (o.value == v){
|
||||||
o.selected = true;
|
o.selected = true;
|
||||||
@ -592,7 +593,7 @@ class UiCode extends UiType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _Input {
|
bricks._Input = class {
|
||||||
constructor(){
|
constructor(){
|
||||||
this.uitypes = [];
|
this.uitypes = [];
|
||||||
}
|
}
|
||||||
@ -607,7 +608,7 @@ class _Input {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
Factory.register(name, Klass);
|
bricks.Factory.register(name, Klass);
|
||||||
this.uitypes[Klass.uitype] = Klass;
|
this.uitypes[Klass.uitype] = Klass;
|
||||||
}
|
}
|
||||||
factory(options){
|
factory(options){
|
||||||
@ -620,7 +621,7 @@ class _Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UiAudio extends UiStr {
|
bricks.UiAudio =class extends bricks.UiStr {
|
||||||
static uitype = 'audio';
|
static uitype = 'audio';
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
super(opts);
|
super(opts);
|
||||||
@ -655,7 +656,7 @@ class UiAudio extends UiStr {
|
|||||||
this.btn.dispatch('click');
|
this.btn.dispatch('click');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class UiVideo extends UiStr {
|
bricks.UiVideo =class extends bricks.UiStr {
|
||||||
static uitype = 'video';
|
static uitype = 'video';
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
super(opts);
|
super(opts);
|
||||||
@ -690,18 +691,18 @@ class UiVideo extends UiStr {
|
|||||||
this.btn.dispatch('click');
|
this.btn.dispatch('click');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var Input = new _Input();
|
var Input = new bricks._Input();
|
||||||
Input.register('UiStr', UiStr);
|
Input.register('UiStr', bricks.UiStr);
|
||||||
Input.register('UiTel', UiTel);
|
Input.register('UiTel', bricks.UiTel);
|
||||||
Input.register('UiDate', UiDate);
|
Input.register('UiDate', bricks.UiDate);
|
||||||
Input.register('UiInt', UiInt);
|
Input.register('UiInt', bricks.UiInt);
|
||||||
Input.register('UiFloat', UiFloat);
|
Input.register('UiFloat', bricks.UiFloat);
|
||||||
Input.register('UiCheck', UiCheck);
|
Input.register('UiCheck', bricks.UiCheck);
|
||||||
Input.register('UiCheckBox', UiCheckBox);
|
Input.register('UiCheckBox', bricks.UiCheckBox);
|
||||||
Input.register('UiEmail', UiEmail);
|
Input.register('UiEmail', bricks.UiEmail);
|
||||||
Input.register('UiFile', UiFile);
|
Input.register('UiFile', bricks.UiFile);
|
||||||
Input.register('UiCode', UiCode);
|
Input.register('UiCode', bricks.UiCode);
|
||||||
Input.register('UiText', UiText);
|
Input.register('UiText', bricks.UiText);
|
||||||
Input.register('UiPassword', UiPassword);
|
Input.register('UiPassword', bricks.UiPassword);
|
||||||
Input.register('UiAudio', UiAudio);
|
Input.register('UiAudio', bricks.UiAudio);
|
||||||
Input.register('UiVideo', UiVideo);
|
Input.register('UiVideo', bricks.UiVideo);
|
||||||
|
@ -40,7 +40,7 @@ class HttpText {
|
|||||||
add_own_params(params){
|
add_own_params(params){
|
||||||
if (! params)
|
if (! params)
|
||||||
params = {};
|
params = {};
|
||||||
var session = bricks_app.get_session();
|
var session = bricks.app.get_session();
|
||||||
if (params instanceof FormData){
|
if (params instanceof FormData){
|
||||||
for ( const [key, value] of Object.entries(this.params)){
|
for ( const [key, value] of Object.entries(this.params)){
|
||||||
params.append(key, value);
|
params.append(key, value);
|
||||||
@ -87,11 +87,11 @@ class HttpText {
|
|||||||
var ck = objget(fetchResult.headers, 'Set-Cookie');
|
var ck = objget(fetchResult.headers, 'Set-Cookie');
|
||||||
if (ck){
|
if (ck){
|
||||||
var session = ck.split(';')[0];
|
var session = ck.split(';')[0];
|
||||||
bricks_app.save_session(session);
|
bricks.app.save_session(session);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (fetchResult.status == 401 && bricks_app.login_url){
|
if (fetchResult.status == 401 && bricks.app.login_url){
|
||||||
return await this.withLoginInfo(url, _params);
|
return await this.withLoginInfo(url, _params);
|
||||||
}
|
}
|
||||||
const resp_error = {
|
const resp_error = {
|
||||||
@ -113,7 +113,7 @@ class HttpText {
|
|||||||
"id":"login_form",
|
"id":"login_form",
|
||||||
"widgettype":"urlwidget",
|
"widgettype":"urlwidget",
|
||||||
"options":{
|
"options":{
|
||||||
"url":bricks_app.login_url
|
"url":bricks.app.login_url
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var login_info = await new Promise((resolve, reject, w) => {
|
var login_info = await new Promise((resolve, reject, w) => {
|
||||||
@ -150,7 +150,7 @@ class HttpText {
|
|||||||
}
|
}
|
||||||
set_authorization_header(params, lgin_info){
|
set_authorization_header(params, lgin_info){
|
||||||
var auth = 'password' + '::' + login_info.user + '::' + login_info.password;
|
var auth = 'password' + '::' + login_info.user + '::' + login_info.password;
|
||||||
var rsa = bricks_app.rsa;
|
var rsa = bricks.app.rsa;
|
||||||
var code = rsa.encrypt(auth);
|
var code = rsa.encrypt(auth);
|
||||||
self.header.authorization = btoa(code)
|
self.header.authorization = btoa(code)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
class Layout extends JsWidget {
|
var bricks = window.bricks || {};
|
||||||
|
bricks.Layout = class extends bricks.JsWidget {
|
||||||
constructor(options){
|
constructor(options){
|
||||||
super(options);
|
super(options);
|
||||||
this._container = true;
|
this._container = true;
|
||||||
@ -51,7 +52,7 @@ class Layout extends JsWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _Body extends Layout {
|
bricks._Body = class extends bricks.Layout {
|
||||||
constructor(options){
|
constructor(options){
|
||||||
super(options);
|
super(options);
|
||||||
}
|
}
|
||||||
@ -61,38 +62,38 @@ class _Body extends Layout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Body = new _Body();
|
bricks.Body = new bricks._Body();
|
||||||
|
|
||||||
class VBox extends Layout {
|
bricks.VBox = class extends bricks.Layout {
|
||||||
constructor(options){
|
constructor(options){
|
||||||
super(options);
|
super(options);
|
||||||
this.set_css('vcontainer');
|
this.set_css('vcontainer');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class VFiller extends Layout {
|
bricks.VFiller = class extends bricks.Layout {
|
||||||
constructor(options){
|
constructor(options){
|
||||||
super(options);
|
super(options);
|
||||||
this.set_css('vfiller');
|
this.set_css('vfiller');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HBox extends Layout {
|
bricks.HBox = class extends bricks.Layout {
|
||||||
constructor(options){
|
constructor(options){
|
||||||
super(options);
|
super(options);
|
||||||
this.set_css('hcontainer');
|
this.set_css('hcontainer');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HFiller extends Layout {
|
bricks.HFiller = class extends bricks.Layout {
|
||||||
constructor(options){
|
constructor(options){
|
||||||
super(options);
|
super(options);
|
||||||
this.set_css('hfiller');
|
this.set_css('hfiller');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.register('HBox', HBox);
|
bricks.Factory.register('HBox', bricks.HBox);
|
||||||
Factory.register('VBox', VBox);
|
bricks.Factory.register('VBox', bricks.VBox);
|
||||||
Factory.register('HFiller', HFiller);
|
bricks.Factory.register('HFiller', bricks.HFiller);
|
||||||
Factory.register('VFiller', VFiller);
|
bricks.Factory.register('VFiller', bricks.VFiller);
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
bricks = window.bricks || {};
|
||||||
/*
|
/*
|
||||||
reply on "https://github.com/markedjs/marked"
|
reply on "https://github.com/markedjs/marked"
|
||||||
add following lines before 'bricks.js'
|
add following lines before 'bricks.js'
|
||||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class MdText extends JsWidget {
|
bricks.MdText = class extends bricks.JsWidget {
|
||||||
/* options
|
/* options
|
||||||
{
|
{
|
||||||
"md_url":
|
"md_url":
|
||||||
@ -41,7 +42,7 @@ class MdText extends JsWidget {
|
|||||||
this.dispatch('loaded', {'url':md_url});
|
this.dispatch('loaded', {'url':md_url});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class MarkdownViewer extends VBox {
|
bricks.MarkdownViewer = class extends bricks.VBox {
|
||||||
/* options
|
/* options
|
||||||
{
|
{
|
||||||
navigator:true
|
navigator:true
|
||||||
@ -125,4 +126,4 @@ class MarkdownViewer extends VBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.register('MarkdownViewer', MarkdownViewer);
|
bricks.Factory.register('MarkdownViewer', bricks.MarkdownViewer);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
bricks = window.bricks || {};
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
class Menu extends VBox {
|
bricks.Menu = class extends bricks.VBox {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
"items":
|
"items":
|
||||||
@ -49,7 +50,7 @@ class Menu extends VBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
create_menuitem(item){
|
create_menuitem(item){
|
||||||
let i18n = bricks_app.i18n;
|
let i18n = bricks.app.i18n;
|
||||||
console.log('i18n=', i18n);
|
console.log('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);
|
||||||
@ -59,4 +60,4 @@ class Menu extends VBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.register('Menu', Menu);
|
bricks.Factory.register('Menu', bricks.Menu);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
class BPopup extends VBox {
|
bricks = window.bricks || {};
|
||||||
|
bricks.BPopup = class extends bricks.VBox {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
holder:
|
holder:
|
||||||
@ -59,7 +60,7 @@ class BPopup extends VBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BMessage extends BPopup {
|
bricks.BMessage = class extends bricks.BPopup {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
title:
|
title:
|
||||||
@ -79,14 +80,14 @@ class BMessage extends BPopup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BError extends BMessage {
|
bricks.BError = class extends bricks.BMessage {
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
super(opts);
|
super(opts);
|
||||||
this.set_css('error');
|
this.set_css('error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PopupForm extends BPopup {
|
bricks.PopupForm = class extends bricks.BPopup {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
form:{
|
form:{
|
||||||
@ -104,6 +105,6 @@ class PopupForm extends BPopup {
|
|||||||
this.dismiss();
|
this.dismiss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Factory.register('BMessage', BMessage);
|
bricks.Factory.register('BMessage', bricks.BMessage);
|
||||||
Factory.register('BError', BError);
|
bricks.Factory.register('BError', bricks.BError);
|
||||||
Factory.register('PopupForm', PopupForm);
|
bricks.Factory.register('PopupForm', bricks.PopupForm);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
class MiniForm extends HBox {
|
bricks = window.bricks || {};
|
||||||
|
bricks.MiniForm = class extends bricks.HBox {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
defaultname:
|
defaultname:
|
||||||
@ -80,4 +81,4 @@ class MiniForm extends HBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.register('MiniForm', MiniForm);
|
bricks.Factory.register('MiniForm', bricks.MiniForm);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
class Modal extends Layout {
|
bricks = window.bricks || {};
|
||||||
|
bricks.Modal = class extends bricks.Layout {
|
||||||
constructor(options){
|
constructor(options){
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@ -81,7 +82,7 @@ class Modal extends Layout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ModalForm extends Modal {
|
bricks.ModalForm = class extends bricks.Modal {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
auto_open:
|
auto_open:
|
||||||
@ -116,6 +117,6 @@ class ModalForm extends Modal {
|
|||||||
this.form.bind('submit', this.dismiss.bind(this));
|
this.form.bind('submit', this.dismiss.bind(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Factory.register('Modal', Modal);
|
bricks.Factory.register('Modal', bricks.Modal);
|
||||||
Factory.register('ModalForm', ModalForm);
|
bricks.Factory.register('ModalForm', bricks.ModalForm);
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
class MultipleStateImage extends Layout {
|
bricks = window.bricks || {};
|
||||||
|
bricks.MultipleStateImage = class extends bricks.Layout {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
state:
|
state:
|
||||||
@ -44,7 +45,7 @@ class MultipleStateImage extends Layout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MultipleStateIcon extends Icon {
|
bricks.MultipleStateIcon = class extends bricks.Icon {
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
opts.url = opts.urls[opts.state];
|
opts.url = opts.urls[opts.state];
|
||||||
super(opts);
|
super(opts);
|
||||||
@ -71,5 +72,6 @@ class MultipleStateIcon extends Icon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Factory.register('MultipleStateImage', MultipleStateImage);
|
bricks.Factory.register('MultipleStateImage', bricks.MultipleStateImage);
|
||||||
|
bricks.Factory.register('MultipleStateIcon', bricks.MultipleStateIcon);
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
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 dir = cur_pos - last_pos;
|
||||||
@ -15,7 +16,7 @@ var low_handle = function(widget, dim, last_pos, cur_pos, maxlen, winsize){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HScrollPanel extends HFiller {
|
bricks.HScrollPanel = class extends bricks.HFiller {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
min_threshold:
|
min_threshold:
|
||||||
@ -49,7 +50,7 @@ class HScrollPanel extends HFiller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class VScrollPanel extends VFiller {
|
bricks.VScrollPanel = class extends bricks.VFiller {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
min_threshold:
|
min_threshold:
|
||||||
@ -81,6 +82,6 @@ class VScrollPanel extends VFiller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.register('VScrollPanel', VScrollPanel);
|
bricks.Factory.register('VScrollPanel', bricks.VScrollPanel);
|
||||||
Factory.register('HScrollPanel', HScrollPanel);
|
bricks.Factory.register('HScrollPanel', bricks.HScrollPanel);
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
class TabPanel extends Layout {
|
bricks = window.bricks || {};
|
||||||
|
bricks.TabPanel = class extends bricks.Layout {
|
||||||
/*
|
/*
|
||||||
options
|
options
|
||||||
{
|
{
|
||||||
@ -122,4 +123,4 @@ class TabPanel extends Layout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.register('TabPanel', TabPanel);
|
bricks.Factory.register('TabPanel', bricks.TabPanel);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
class Toolbar extends Layout {
|
bricks = window.bricks || {};
|
||||||
|
bricks.Toolbar = class extends bricks.Layout {
|
||||||
/* toolbar options
|
/* toolbar options
|
||||||
{
|
{
|
||||||
orientation:
|
orientation:
|
||||||
@ -127,4 +128,4 @@ class Toolbar extends Layout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.register('Toolbar', Toolbar);
|
bricks.Factory.register('Toolbar', bricks.Toolbar);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
class TreeNode extends VBox {
|
bricks = window.bricks || {};
|
||||||
|
bricks. TreeNode = class extends bricks.VBox {
|
||||||
constructor(tree, parent, data){
|
constructor(tree, parent, data){
|
||||||
var opts = {
|
var opts = {
|
||||||
width:'100%',
|
width:'100%',
|
||||||
@ -20,7 +21,7 @@ class TreeNode extends VBox {
|
|||||||
overflow:'hidden',
|
overflow:'hidden',
|
||||||
width:'100%'
|
width:'100%'
|
||||||
})
|
})
|
||||||
n.dom_element.style.margin = bricks_app.charsize * 0.2;
|
n.dom_element.style.margin = bricks.app.charsize * 0.2;
|
||||||
this.add_widget(n);
|
this.add_widget(n);
|
||||||
n.bind('click', this.tree.node_click_handle.bind(this.tree, this));
|
n.bind('click', this.tree.node_click_handle.bind(this.tree, this));
|
||||||
this.node_widget = n;
|
this.node_widget = n;
|
||||||
@ -28,7 +29,7 @@ class TreeNode extends VBox {
|
|||||||
if (! this.data.is_leaf) {
|
if (! this.data.is_leaf) {
|
||||||
this.container = new VBox({height:'auto', overflow:'hidden'});
|
this.container = new VBox({height:'auto', overflow:'hidden'});
|
||||||
this.add_widget(this.container);
|
this.add_widget(this.container);
|
||||||
this.container.dom_element.style.marginLeft = bricks_app.charsize + 'px';
|
this.container.dom_element.style.marginLeft = bricks.app.charsize + 'px';
|
||||||
if (this.data.children){
|
if (this.data.children){
|
||||||
this.tree.create_node_children(this, this.data.children);
|
this.tree.create_node_children(this, this.data.children);
|
||||||
}
|
}
|
||||||
@ -66,7 +67,7 @@ class TreeNode extends VBox {
|
|||||||
this.container.hide();
|
this.container.hide();
|
||||||
}
|
}
|
||||||
create_node_content(widget){
|
create_node_content(widget){
|
||||||
var img_size = bricks_app.charsize;
|
var img_size = bricks.app.charsize;
|
||||||
if (this.is_leaf){
|
if (this.is_leaf){
|
||||||
widget.add_widget(new BlankIcon({}));
|
widget.add_widget(new BlankIcon({}));
|
||||||
} else {
|
} else {
|
||||||
@ -121,7 +122,7 @@ class TreeNode extends VBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Tree extends VBox {
|
bricks. Tree = class extends bricks.VBox {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
row_height:
|
row_height:
|
||||||
@ -192,7 +193,7 @@ class Tree extends VBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class EditableTree extends Tree {
|
bricks. EditableTree = class extends bricks.Tree {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
@ -330,7 +331,7 @@ class EditableTree extends Tree {
|
|||||||
this.selected_node.move_botton();
|
this.selected_node.move_botton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class PolymorphyTree extends Tree {
|
bricks. PolymorphyTree = class extends bricks.Tree {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
root:[t1],
|
root:[t1],
|
||||||
@ -352,5 +353,5 @@ class PolymorphyTree extends Tree {
|
|||||||
super(opts);
|
super(opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Factory.register('Tree', Tree);
|
bricks.Factory.register('Tree', bricks.Tree);
|
||||||
Factory.register('EditableTree', EditableTree);
|
bricks.Factory.register('EditableTree', bricks.EditableTree);
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
bricks = window.bricks || {};
|
||||||
/*
|
/*
|
||||||
we use videojs for video play
|
we use videojs for video play
|
||||||
https://videojs.com
|
https://videojs.com
|
||||||
*/
|
*/
|
||||||
class Video extends JsWidget {
|
bricks.Video = class extends bricks.JsWidget {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
vtype:
|
vtype:
|
||||||
@ -39,7 +40,7 @@ class Video extends JsWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class VideoPlayer extends VBox {
|
bricks.VideoPlayer = class extends bricks.VBox {
|
||||||
/*
|
/*
|
||||||
we use [indigo-player](https://github.com/matvp91/indigo-player) as a base.
|
we use [indigo-player](https://github.com/matvp91/indigo-player) as a base.
|
||||||
inside body, need to add following line before bricks.js
|
inside body, need to add following line before bricks.js
|
||||||
@ -68,5 +69,5 @@ class VideoPlayer extends VBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Factory.register('VideoPlayer', VideoPlayer);
|
bricks.Factory.register('VideoPlayer', bricks.VideoPlayer);
|
||||||
Factory.register('Video', Video);
|
bricks.Factory.register('Video', bricks.Video);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
bricks = window.bricks || {};
|
||||||
class JsWidget {
|
bricks.JsWidget = class {
|
||||||
dom_element = null;
|
dom_element = null;
|
||||||
constructor(options){
|
constructor(options){
|
||||||
if (!options){
|
if (!options){
|
||||||
@ -74,7 +74,7 @@ class JsWidget {
|
|||||||
|
|
||||||
}
|
}
|
||||||
sizable(){
|
sizable(){
|
||||||
bricks_app.text_ref(this);
|
bricks.app.text_ref(this);
|
||||||
}
|
}
|
||||||
change_fontsize(ts){
|
change_fontsize(ts){
|
||||||
ts = convert2int(ts);
|
ts = convert2int(ts);
|
||||||
@ -94,7 +94,7 @@ class JsWidget {
|
|||||||
this.specified_fontsize = true;
|
this.specified_fontsize = true;
|
||||||
fontsize = this.opts.fontsize;
|
fontsize = this.opts.fontsize;
|
||||||
} else {
|
} else {
|
||||||
fontsize = bricks_app.get_textsize(this.ctype);
|
fontsize = bricks.app.get_textsize(this.ctype);
|
||||||
}
|
}
|
||||||
fontsize = convert2int(fontsize);
|
fontsize = convert2int(fontsize);
|
||||||
var rate = this.rate || 1;
|
var rate = this.rate || 1;
|
||||||
@ -195,7 +195,7 @@ class JsWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class TextBase extends JsWidget {
|
bricks.TextBase = class extends bricks.JsWidget {
|
||||||
/* {
|
/* {
|
||||||
otext:
|
otext:
|
||||||
i18n:
|
i18n:
|
||||||
@ -245,7 +245,7 @@ class TextBase extends JsWidget {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Text extends TextBase {
|
bricks.Text = class extends bricks.TextBase {
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
super(opts);
|
super(opts);
|
||||||
this.ctype = 'text';
|
this.ctype = 'text';
|
||||||
@ -253,7 +253,7 @@ class Text extends TextBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Title1 extends TextBase {
|
bricks.Title1 = class extends bricks.TextBase {
|
||||||
constructor(options){
|
constructor(options){
|
||||||
super(options);
|
super(options);
|
||||||
this.ctype = 'title1';
|
this.ctype = 'title1';
|
||||||
@ -262,7 +262,7 @@ class Title1 extends TextBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Title2 extends TextBase {
|
bricks.Title2 = class extends bricks.TextBase {
|
||||||
constructor(options){
|
constructor(options){
|
||||||
super(options);
|
super(options);
|
||||||
this.ctype = 'title2';
|
this.ctype = 'title2';
|
||||||
@ -271,7 +271,7 @@ class Title2 extends TextBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Title3 extends TextBase {
|
bricks.Title3 = class extends bricks.TextBase {
|
||||||
constructor(options){
|
constructor(options){
|
||||||
super(options);
|
super(options);
|
||||||
this.ctype = 'title3';
|
this.ctype = 'title3';
|
||||||
@ -280,7 +280,7 @@ class Title3 extends TextBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Title4 extends TextBase {
|
bricks.Title4 = class extends bricks.TextBase {
|
||||||
constructor(options){
|
constructor(options){
|
||||||
super(options);
|
super(options);
|
||||||
this.ctype = 'title4';
|
this.ctype = 'title4';
|
||||||
@ -289,7 +289,7 @@ class Title4 extends TextBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Title5 extends TextBase {
|
bricks.Title5 = class extends bricks.TextBase {
|
||||||
constructor(options){
|
constructor(options){
|
||||||
super(options);
|
super(options);
|
||||||
this.ctype = 'title5';
|
this.ctype = 'title5';
|
||||||
@ -298,7 +298,7 @@ class Title5 extends TextBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Title6 extends TextBase {
|
bricks.Title6 = class extends bricks.TextBase {
|
||||||
constructor(options){
|
constructor(options){
|
||||||
super(options);
|
super(options);
|
||||||
this.ctype = 'title6';
|
this.ctype = 'title6';
|
||||||
@ -307,11 +307,11 @@ class Title6 extends TextBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.register('Text', Text);
|
bricks.Factory.register('Text', bricks.Text);
|
||||||
Factory.register('Title1', Title1);
|
bricks.Factory.register('Title1', bricks.Title1);
|
||||||
Factory.register('Title2', Title2);
|
bricks.Factory.register('Title2', bricks.Title2);
|
||||||
Factory.register('Title3', Title3);
|
bricks.Factory.register('Title3', bricks.Title3);
|
||||||
Factory.register('Title4', Title4);
|
bricks.Factory.register('Title4', bricks.Title4);
|
||||||
Factory.register('Title5', Title5);
|
bricks.Factory.register('Title5', bricks.Title5);
|
||||||
Factory.register('Title6', Title6);
|
bricks.Factory.register('Title6', bricks.Title6);
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
bricks = window.bricks || {};
|
||||||
/*
|
/*
|
||||||
dependent on xterm.js
|
dependent on xterm.js
|
||||||
*/
|
*/
|
||||||
class Wterm extends JsWidget {
|
bricks.Wterm = class extends bricks.JsWidget {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
ws_url:
|
ws_url:
|
||||||
@ -48,5 +49,5 @@ class Wterm extends JsWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.register('Wterm', Wterm);
|
bricks.Factory.register('Wterm', bricks.Wterm);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user