This commit is contained in:
yumoqing 2024-02-21 23:00:49 +08:00
parent 6ff89c03a8
commit 8e1239a8e6
15 changed files with 39 additions and 32 deletions

View File

@ -227,7 +227,7 @@ bricks.buildUrlwidgetHandler = function(w, target, rtdata, desc){
target.add_widget(w); target.add_widget(w);
} }
var options = objcopy(desc.options); var options = objcopy(desc.options);
extend(options.params, rtdata); bricks.extend(options.params, rtdata);
var opts = { var opts = {
"widgettype":"urlwidget", "widgettype":"urlwidget",
"options":options "options":options
@ -248,7 +248,7 @@ bricks.buildBricksHandler = function(w, target, rtdata, desc){
target.add_widget(w); target.add_widget(w);
} }
var options = objcopy(desc.options); var options = objcopy(desc.options);
extend(options.options, rtdata); bricks.extend(options.options, rtdata);
return f.bind(target, target, desc.mode || 'replace', options); return f.bind(target, target, desc.mode || 'replace', options);
} }
bricks.buildRegisterFunctionHandler = function(w, target, rtdata, desc){ bricks.buildRegisterFunctionHandler = function(w, target, rtdata, desc){
@ -259,10 +259,10 @@ bricks.buildRegisterFunctionHandler = function(w, target, rtdata, desc){
} }
var params = {}; var params = {};
if (desc.params){ if (desc.params){
extend(params, desc.params); bricks.extend(params, desc.params);
} }
if (rtdata){ if (rtdata){
extend(params, rtdata); bricks.extend(params, rtdata);
} }
return f.bind(target, params); return f.bind(target, params);
} }
@ -273,22 +273,22 @@ bricks.buildMethodHandler = function(w, target, rtdata, desc){
return null; return null;
} }
var params = {}; var params = {};
extend(params, desc.params) bricks.extend(params, desc.params)
extend(params, rtdata); bricks.extend(params, rtdata);
return f.bind(target, params); return f.bind(target, params);
} }
bricks.buildScriptHandler = function(w, target, rtdata, desc){ bricks.buildScriptHandler = function(w, target, rtdata, desc){
var params = {}; var params = {};
extend(params, desc.params) bricks.extend(params, desc.params)
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() ..........'); console.log('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){
var params = {}; var params = {};
extend(params, desc.params) bricks.extend(params, desc.params)
extend(params, rtdata); bricks.extend(params, rtdata);
var f = function(target, event_name, params){ var f = function(target, event_name, params){
target.dispatch(event_name, params); target.dispatch(event_name, params);
} }

View File

@ -50,7 +50,7 @@ bricks.Button = class extends bricks.Layout {
this.item_rate = opts.item_rate || 1; this.item_rate = opts.item_rate || 1;
this.set_id(this.opts.name); this.set_id(this.opts.name);
this.opts_setup(); this.opts_setup();
extend(this.dom_element.style, style); bricks.extend(this.dom_element.style, style);
} }
create(){ create(){
this.dom_element = document.createElement('button'); this.dom_element = document.createElement('button');

View File

@ -23,7 +23,7 @@ bricks.Row = class {
var f = fields[i]; var f = fields[i];
var opts = f.uioptions || {}; var opts = f.uioptions || {};
var w; var w;
extend(opts, { bricks.extend(opts, {
name: f.name, name: f.name,
label: f.label, label: f.label,
uitype: f.uitype, uitype: f.uitype,

View File

@ -52,7 +52,7 @@ bricks.FormBody = class extends bricks.VBox {
w.focus(); w.focus();
return; return;
} }
extend(data, d); bricks.extend(data, d);
} }
return data; return data;
} }

View File

@ -30,7 +30,7 @@ bricks.I18n = class {
} }
setup_dict(dic, lang){ setup_dict(dic, lang){
this.cur_lang = lang; this.cur_lang = lang;
extend(this.lang_msgs, {lang:dic}); bricks.extend(this.lang_msgs, {lang:dic});
this.msgs = dic; this.msgs = dic;
} }
async change_lang(lang){ async change_lang(lang){

View File

@ -293,7 +293,7 @@ bricks.UiCheck =class extends bricks.UiType {
static uitype = 'check'; static uitype = 'check';
constructor(opts){ constructor(opts){
super(opts); super(opts);
extend(UiCheck.prototype, Layout.prototype); bricks.extend(UiCheck.prototype, Layout.prototype);
this.add_widget = Layout.prototype.add_widget.bind(this); this.add_widget = Layout.prototype.add_widget.bind(this);
this.dom_element.style.width = 'auto'; this.dom_element.style.width = 'auto';
this.dom_element.style.height = 'auto'; this.dom_element.style.height = 'auto';
@ -559,7 +559,7 @@ bricks.UiCode =class extends bricks.UiType {
async get_data(event){ async get_data(event){
var params = this.opts.params; var params = this.opts.params;
if(event){ if(event){
extend(params, event.params); bricks.extend(params, event.params);
} }
var jcall = bricks.jcall; var jcall = bricks.jcall;
var d = await jcall(this.opts.dataurl, var d = await jcall(this.opts.dataurl,

View File

@ -17,7 +17,7 @@ bricks.HttpText = class {
this.headers = headers || { this.headers = headers || {
"Accept":"text/html", "Accept":"text/html",
}; };
extend(this.headers, headers); bricks.extend(this.headers, headers);
this.params = { this.params = {
"_webbricks_":1 "_webbricks_":1
} }
@ -53,7 +53,7 @@ bricks.HttpText = class {
} }
params = Object.assign(this.params, params); params = Object.assign(this.params, params);
if (session){ if (session){
extend(params,{session:session}); bricks.extend(params,{session:session});
} }
return params; return params;
} }
@ -191,7 +191,7 @@ bricks.HttpJson = class extends bricks.HttpText {
this.headers = { this.headers = {
"Accept": "application/json", "Accept": "application/json",
} }
extend(this.headers, headers); bricks.extend(this.headers, headers);
} }
async get_result_data(resp) { async get_result_data(resp) {
return await resp.json() return await resp.json()

View File

@ -76,7 +76,7 @@ bricks.MiniForm = class extends bricks.HBox {
getValue(){ getValue(){
var d = this.opts.params || {}; var d = this.opts.params || {};
var v = this.input.getValue(); var v = this.input.getValue();
extend(d, v); bricks.extend(d, v);
return d; return d;
} }
} }

View File

@ -38,7 +38,7 @@ bricks.BufferedDataLoader = class {
this.buffer = {}; this.buffer = {};
if (!params) params = {}; if (!params) params = {};
var p = objcopy(this.params); var p = objcopy(this.params);
extend(p, params); bricks.extend(p, params);
p.rows = this.pagerows; p.rows = this.pagerows;
this.cur_params = p; this.cur_params = p;
this.cur_page = 1; this.cur_page = 1;

View File

@ -3,7 +3,7 @@ class RegisterFunction {
this.rfs = {}; this.rfs = {};
} }
register(n, f){ register(n, f){
extend(this.rfs, {n:f}); bricks.extend(this.rfs, {n:f});
} }
get(n){ get(n){
return objget(this.rfs, n); return objget(this.rfs, n);

View File

@ -16,7 +16,7 @@ var low_handle = function(widget, dim, last_pos, cur_pos, maxlen, winsize){
} }
} }
bricks.HScrollPanel = class extends bricks.HFiller { bricks.HScrollPanel = class extends bricks.HBox {
/* /*
{ {
min_threshold: min_threshold:
@ -24,7 +24,10 @@ bricks.HScrollPanel = class extends bricks.HFiller {
} }
*/ */
constructor(opts){ constructor(opts){
opts.width = '100%';
opts.height = '100%';
super(opts); super(opts);
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))
@ -50,7 +53,7 @@ bricks.HScrollPanel = class extends bricks.HFiller {
} }
} }
bricks.VScrollPanel = class extends bricks.VFiller { bricks.VScrollPanel = class extends bricks.VBox {
/* /*
{ {
min_threshold: min_threshold:
@ -58,6 +61,8 @@ bricks.VScrollPanel = class extends bricks.VFiller {
} }
*/ */
constructor(opts){ constructor(opts){
opts.width = '100%';
opts.height = '100%';
super(opts); super(opts);
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;

View File

@ -95,7 +95,7 @@ bricks.Toolbar = class extends bricks.Layout {
console.log('Toolbar() onclock,target=', event.target, tool); console.log('Toolbar() onclock,target=', event.target, tool);
var e = new Event('command'); var e = new Event('command');
var d = {}; var d = {};
extend(d, tool.tool_opts); bricks.extend(d, tool.tool_opts);
if (this.opts.target){ if (this.opts.target){
d.target = this.opts.target; d.target = this.opts.target;
} }

View File

@ -107,7 +107,7 @@ bricks.uitypesdef.setViewBuilder('float', floatViewBuilder);
var codeViewBuilder = function(desc, rec){ var codeViewBuilder = function(desc, rec){
var opts = objcopy(desc) var opts = objcopy(desc)
if (opts.uiparams) extend(opts, opts.uiparams); if (opts.uiparams) bricks.extend(opts, opts.uiparams);
var name = desc.textFeild || 'text'; var name = desc.textFeild || 'text';
var v = rec[name]; var v = rec[name];
if (! v) { if (! v) {

View File

@ -1,4 +1,6 @@
var bricks = window.bricks || {}; var bricks = window.bricks || {};
bricks.isMobile = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
class _TypeIcons { class _TypeIcons {
constructor(){ constructor(){
this.kv = {} this.kv = {}
@ -37,10 +39,10 @@ var currentScriptPath = function () {
return currentScript.replace( currentScriptFile, '' ); return currentScript.replace( currentScriptFile, '' );
} }
var bricks_path = currentScriptPath(); bricks.path = currentScriptPath();
var bricks_resource = function(name){ var bricks_resource = function(name){
return bricks_path + name; return bricks.path + name;
} }
/** /**
@ -108,14 +110,14 @@ var import_js = async function(url){
} }
var extend = function(d, s){ bricks.extend = function(d, s){
for (var p in s){ for (var p in s){
if (! s.hasOwnProperty(p)){ if (! s.hasOwnProperty(p)){
continue; continue;
} }
if (d[p] && (typeof(d[p]) == 'object') if (d[p] && (typeof(d[p]) == 'object')
&& (d[p].toString() == '[object Object]') && s[p]){ && (d[p].toString() == '[object Object]') && s[p]){
extend(d[p], s[p]); bricks.extend(d[p], s[p]);
} else { } else {
d[p] = s[p]; d[p] = s[p];
} }

View File

@ -67,7 +67,7 @@ bricks.JsWidget = class {
} }
this[okeys[k]] = this.opts[okeys[k]]; this[okeys[k]] = this.opts[okeys[k]];
} }
extend(this.dom_element.style, style); bricks.extend(this.dom_element.style, style);
if (this.opts.css){ if (this.opts.css){
this.set_css(this.opts.css); this.set_css(this.opts.css);
} }
@ -155,7 +155,7 @@ bricks.JsWidget = class {
} }
} }
set_cssObject(cssobj){ set_cssObject(cssobj){
extend(this.dom_element.style, cssobj); bricks.extend(this.dom_element.style, cssobj);
} }
is_container(){ is_container(){
return this._container; return this._container;