diff --git a/bricks/bricks.js b/bricks/bricks.js index 0750090..5603984 100755 --- a/bricks/bricks.js +++ b/bricks/bricks.js @@ -227,7 +227,7 @@ bricks.buildUrlwidgetHandler = function(w, target, rtdata, desc){ target.add_widget(w); } var options = objcopy(desc.options); - extend(options.params, rtdata); + bricks.extend(options.params, rtdata); var opts = { "widgettype":"urlwidget", "options":options @@ -248,7 +248,7 @@ bricks.buildBricksHandler = function(w, target, rtdata, desc){ target.add_widget(w); } var options = objcopy(desc.options); - extend(options.options, rtdata); + bricks.extend(options.options, rtdata); return f.bind(target, target, desc.mode || 'replace', options); } bricks.buildRegisterFunctionHandler = function(w, target, rtdata, desc){ @@ -259,10 +259,10 @@ bricks.buildRegisterFunctionHandler = function(w, target, rtdata, desc){ } var params = {}; if (desc.params){ - extend(params, desc.params); + bricks.extend(params, desc.params); } if (rtdata){ - extend(params, rtdata); + bricks.extend(params, rtdata); } return f.bind(target, params); } @@ -273,22 +273,22 @@ bricks.buildMethodHandler = function(w, target, rtdata, desc){ return null; } var params = {}; - extend(params, desc.params) - extend(params, rtdata); + bricks.extend(params, desc.params) + bricks.extend(params, rtdata); return f.bind(target, params); } bricks.buildScriptHandler = function(w, target, rtdata, desc){ var params = {}; - extend(params, desc.params) - extend(params, rtdata); + bricks.extend(params, desc.params) + bricks.extend(params, rtdata); var f = new Function('target', 'params', 'event', desc.script); console.log('params=', params, 'buildScriptHandler() ..........'); return f.bind(target, target, params); } bricks.buildDispatchEventHandler = function(w, target, rtdata, desc){ var params = {}; - extend(params, desc.params) - extend(params, rtdata); + bricks.extend(params, desc.params) + bricks.extend(params, rtdata); var f = function(target, event_name, params){ target.dispatch(event_name, params); } diff --git a/bricks/button.js b/bricks/button.js index e685a41..0853532 100644 --- a/bricks/button.js +++ b/bricks/button.js @@ -50,7 +50,7 @@ bricks.Button = class extends bricks.Layout { this.item_rate = opts.item_rate || 1; this.set_id(this.opts.name); this.opts_setup(); - extend(this.dom_element.style, style); + bricks.extend(this.dom_element.style, style); } create(){ this.dom_element = document.createElement('button'); diff --git a/bricks/datagrid.js b/bricks/datagrid.js index ce2e1e1..cb8e9f0 100644 --- a/bricks/datagrid.js +++ b/bricks/datagrid.js @@ -23,7 +23,7 @@ bricks.Row = class { var f = fields[i]; var opts = f.uioptions || {}; var w; - extend(opts, { + bricks.extend(opts, { name: f.name, label: f.label, uitype: f.uitype, diff --git a/bricks/form.js b/bricks/form.js index 8043757..505c742 100644 --- a/bricks/form.js +++ b/bricks/form.js @@ -52,7 +52,7 @@ bricks.FormBody = class extends bricks.VBox { w.focus(); return; } - extend(data, d); + bricks.extend(data, d); } return data; } diff --git a/bricks/i18n.js b/bricks/i18n.js index 347fb73..363ce2a 100755 --- a/bricks/i18n.js +++ b/bricks/i18n.js @@ -30,7 +30,7 @@ bricks.I18n = class { } setup_dict(dic, lang){ this.cur_lang = lang; - extend(this.lang_msgs, {lang:dic}); + bricks.extend(this.lang_msgs, {lang:dic}); this.msgs = dic; } async change_lang(lang){ diff --git a/bricks/input.js b/bricks/input.js index def6fed..8e42c44 100755 --- a/bricks/input.js +++ b/bricks/input.js @@ -293,7 +293,7 @@ bricks.UiCheck =class extends bricks.UiType { static uitype = 'check'; constructor(opts){ super(opts); - extend(UiCheck.prototype, Layout.prototype); + bricks.extend(UiCheck.prototype, Layout.prototype); this.add_widget = Layout.prototype.add_widget.bind(this); this.dom_element.style.width = 'auto'; this.dom_element.style.height = 'auto'; @@ -559,7 +559,7 @@ bricks.UiCode =class extends bricks.UiType { async get_data(event){ var params = this.opts.params; if(event){ - extend(params, event.params); + bricks.extend(params, event.params); } var jcall = bricks.jcall; var d = await jcall(this.opts.dataurl, diff --git a/bricks/jsoncall.js b/bricks/jsoncall.js index 4be50e3..6b74b98 100755 --- a/bricks/jsoncall.js +++ b/bricks/jsoncall.js @@ -17,7 +17,7 @@ bricks.HttpText = class { this.headers = headers || { "Accept":"text/html", }; - extend(this.headers, headers); + bricks.extend(this.headers, headers); this.params = { "_webbricks_":1 } @@ -53,7 +53,7 @@ bricks.HttpText = class { } params = Object.assign(this.params, params); if (session){ - extend(params,{session:session}); + bricks.extend(params,{session:session}); } return params; } @@ -191,7 +191,7 @@ bricks.HttpJson = class extends bricks.HttpText { this.headers = { "Accept": "application/json", } - extend(this.headers, headers); + bricks.extend(this.headers, headers); } async get_result_data(resp) { return await resp.json() diff --git a/bricks/miniform.js b/bricks/miniform.js index c5ce22e..7de2740 100644 --- a/bricks/miniform.js +++ b/bricks/miniform.js @@ -76,7 +76,7 @@ bricks.MiniForm = class extends bricks.HBox { getValue(){ var d = this.opts.params || {}; var v = this.input.getValue(); - extend(d, v); + bricks.extend(d, v); return d; } } diff --git a/bricks/paging.js b/bricks/paging.js index 200651b..15d927e 100644 --- a/bricks/paging.js +++ b/bricks/paging.js @@ -38,7 +38,7 @@ bricks.BufferedDataLoader = class { this.buffer = {}; if (!params) params = {}; var p = objcopy(this.params); - extend(p, params); + bricks.extend(p, params); p.rows = this.pagerows; this.cur_params = p; this.cur_page = 1; diff --git a/bricks/registerfunction.js b/bricks/registerfunction.js index 4e5cfa1..3a04e31 100755 --- a/bricks/registerfunction.js +++ b/bricks/registerfunction.js @@ -3,7 +3,7 @@ class RegisterFunction { this.rfs = {}; } register(n, f){ - extend(this.rfs, {n:f}); + bricks.extend(this.rfs, {n:f}); } get(n){ return objget(this.rfs, n); diff --git a/bricks/scroll.js b/bricks/scroll.js index b29b2b8..ec58e11 100644 --- a/bricks/scroll.js +++ b/bricks/scroll.js @@ -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: @@ -24,7 +24,10 @@ bricks.HScrollPanel = class extends bricks.HFiller { } */ constructor(opts){ + opts.width = '100%'; + opts.height = '100%'; super(opts); + this.min_threshold = opts.min_threshold || 0.02; this.max_threshold = opts.max_threshold || 0.95; 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: @@ -58,6 +61,8 @@ bricks.VScrollPanel = class extends bricks.VFiller { } */ constructor(opts){ + opts.width = '100%'; + opts.height = '100%'; super(opts); this.min_threshold = opts.min_threshold || 0.02; this.max_threshold = opts.max_threshold || 0.95; diff --git a/bricks/toolbar.js b/bricks/toolbar.js index b34763f..7a1a97b 100755 --- a/bricks/toolbar.js +++ b/bricks/toolbar.js @@ -95,7 +95,7 @@ bricks.Toolbar = class extends bricks.Layout { console.log('Toolbar() onclock,target=', event.target, tool); var e = new Event('command'); var d = {}; - extend(d, tool.tool_opts); + bricks.extend(d, tool.tool_opts); if (this.opts.target){ d.target = this.opts.target; } diff --git a/bricks/uitypesdef.js b/bricks/uitypesdef.js index a18c5d0..ae53893 100755 --- a/bricks/uitypesdef.js +++ b/bricks/uitypesdef.js @@ -107,7 +107,7 @@ bricks.uitypesdef.setViewBuilder('float', floatViewBuilder); var codeViewBuilder = function(desc, rec){ 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 v = rec[name]; if (! v) { diff --git a/bricks/utils.js b/bricks/utils.js index 1636250..c6ee0e4 100755 --- a/bricks/utils.js +++ b/bricks/utils.js @@ -1,4 +1,6 @@ var bricks = window.bricks || {}; +bricks.isMobile = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); + class _TypeIcons { constructor(){ this.kv = {} @@ -37,10 +39,10 @@ var currentScriptPath = function () { return currentScript.replace( currentScriptFile, '' ); } -var bricks_path = currentScriptPath(); +bricks.path = currentScriptPath(); 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){ if (! s.hasOwnProperty(p)){ continue; } if (d[p] && (typeof(d[p]) == 'object') && (d[p].toString() == '[object Object]') && s[p]){ - extend(d[p], s[p]); + bricks.extend(d[p], s[p]); } else { d[p] = s[p]; } diff --git a/bricks/widget.js b/bricks/widget.js index 04b0fce..34a7247 100755 --- a/bricks/widget.js +++ b/bricks/widget.js @@ -67,7 +67,7 @@ bricks.JsWidget = class { } this[okeys[k]] = this.opts[okeys[k]]; } - extend(this.dom_element.style, style); + bricks.extend(this.dom_element.style, style); if (this.opts.css){ this.set_css(this.opts.css); } @@ -155,7 +155,7 @@ bricks.JsWidget = class { } } set_cssObject(cssobj){ - extend(this.dom_element.style, cssobj); + bricks.extend(this.dom_element.style, cssobj); } is_container(){ return this._container;