This commit is contained in:
yumoqing 2024-10-25 22:06:59 +08:00
parent 691648791b
commit 06b230fb95
7 changed files with 42 additions and 6 deletions

View File

@ -63,6 +63,10 @@ bricks.Accordion = class extends bricks.VBox {
}
var c = objget(this.subcontents,name);
if (refresh || ! c ){
if (!this.opts.items[pos].content){
console.log('***', pos, 'item dont has content');
return;
}
c = await bricks.widgetBuild(this.opts.items[pos].content);
this.subcontents[name] = c;
}

View File

@ -232,7 +232,7 @@ bricks.AudioRecorder = class extends bricks.HBox {
downA.href=this.recordData.url;
downA.download=fileName;
// document.querySelector("."+cls).appendChild(downA);
if(/mobile/i.test(navigator.userAgent)){
if(bricks.is_mobile()){
bricks.debug('mobile device');
}
downA.click();

View File

@ -460,7 +460,7 @@ bricks.App = class extends bricks.Layout {
*/
super(opts);
bricks.app = this;
bricks.bug = opts.debug or false;
bricks.bug = opts.debug || false;
bricks.Body = this;
this.deviceid = bricks.deviceid(opts.appname || 'appname');
this.login_url = opts.login_url;
@ -483,6 +483,12 @@ bricks.App = class extends bricks.Layout {
this._Height = this.dom_element.offsetHeight;
document.addEventListener('keydown', this.key_down_action.bind(this));
}
screenHeight(){
return this.dom_element.clientHeight;
}
screenWidth(){
return this.dom_element.clientWidth;
}
create(){
this.dom_element = document.getElementsByTagName('body')[0];
this.set_baseURI(this.dom_element.baseURI);

View File

@ -43,8 +43,16 @@ bricks.HttpText = class {
"Accept":"text/html",
};
bricks.extend(this.headers, headers);
var width=0, height=0;
if (bricks.app) {
width = bricks.app.screenWidth();
height = bricks.app.screenHeight();
}
this.params = {
"_webbricks_":1
"_webbricks_":1,
"width":width,
"height":height,
"_is_mobile":bricks.is_mobile()
}
}
url_parse(url){

View File

@ -139,6 +139,9 @@ bricks.Layout = class extends bricks.JsWidget {
} else {
// append child at end
w.parent = this;
if (this.baseURI && !w.baseURI){
w.set_baseURI(this.baseURI);
}
this.children.push(w);
this.dom_element.appendChild(w.dom_element);
}

View File

@ -21,7 +21,11 @@ bricks.debug = function(...args){
try {
throw new Error();
} catch (e) {
try {
callInfo = e.stack.split('\n')[2].trim();
} catch (e1) {
callInfo = e.toString();
}
}
console.log(callInfo, ...args);
}
@ -259,6 +263,9 @@ bricks.absurl = function(url, widget){
return url;
}
var base_uri = widget.baseURI;
if (!base_uri){
base_uri = bricks.Body.baseURI;
}
if (url.startsWith('/')){
base_uri = bricks.Body.baseURI;
url = url.substring(1);

View File

@ -211,8 +211,16 @@ bricks.JsWidget = class {
this.id = id;
this.dom_element.id = id;
}
set_baseURI(url){
this.baseURI = url;
set_baseURI(uri){
this.baseURI = uri;
if (!this._container){
return;
}
this.children.forEach(c =>{
if (!c.baseURI){
c.set_baseURI(uri);
}
});
}
show(){
this.dom_element.style.display = '';