bugfix
This commit is contained in:
parent
f5d692a192
commit
f1842722b4
@ -219,13 +219,27 @@ bricks.universal_handler = async function(from_widget, widget, desc, event){
|
|||||||
event);
|
event);
|
||||||
}
|
}
|
||||||
bricks.buildEventHandler = async function(w, desc, event){
|
bricks.buildEventHandler = async function(w, desc, event){
|
||||||
var target = bricks.getWidgetById(desc.target, w);
|
var target;
|
||||||
|
if (desc.target == 'Popup'){
|
||||||
|
var popts = bricks.get_popup_default_options();
|
||||||
|
var opt1 = desc.popup_options || {};
|
||||||
|
bricks.extend(popts, opt1);
|
||||||
|
target = new bricks.Popup(popts);
|
||||||
|
} else if (desc.target == 'PopupWindow') {
|
||||||
|
var popts = bricks.get_popupwindow_default_options();
|
||||||
|
var opt1 = desc.popup_options || {};
|
||||||
|
bricks.extend(popts, opt1);
|
||||||
|
target = new bricks.PopupWindow(popts);
|
||||||
|
} else {
|
||||||
|
target = bricks.getWidgetById(desc.target, w);
|
||||||
|
}
|
||||||
if (! target){
|
if (! target){
|
||||||
bricks.debug('target miss desc=', desc, 'w=', w);
|
bricks.debug('target miss desc=', desc, 'w=', w);
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
var rtdata = {};
|
var rtdata = {};
|
||||||
desc.event_params = event.params || {} ;
|
desc.event_params = event.params || {} ;
|
||||||
|
desc.event = event;
|
||||||
if (desc.rtdata) rtdata = desc.rtdata;
|
if (desc.rtdata) rtdata = desc.rtdata;
|
||||||
else if (desc.datawidget){
|
else if (desc.datawidget){
|
||||||
var data_desc = {
|
var data_desc = {
|
||||||
@ -236,15 +250,6 @@ bricks.buildEventHandler = async function(w, desc, event){
|
|||||||
}
|
}
|
||||||
rtdata = await bricks.getRealtimeData(w, data_desc);
|
rtdata = await bricks.getRealtimeData(w, data_desc);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if (typeof event.params == typeof {}){
|
|
||||||
rtdata = bricks.extend(rtdata, event.params);
|
|
||||||
} else if (event.params instanceof FormData){
|
|
||||||
for ( const [key, value] of Object.entries(rtdata)){
|
|
||||||
params.append(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
switch (desc.actiontype){
|
switch (desc.actiontype){
|
||||||
case 'urlwidget':
|
case 'urlwidget':
|
||||||
return bricks.buildUrlwidgetHandler(w, target, rtdata, desc);
|
return bricks.buildUrlwidgetHandler(w, target, rtdata, desc);
|
||||||
@ -290,45 +295,31 @@ bricks.getRealtimeData = async function(w, desc){
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _buildWidget = async function(from_widget, target, mode, options){
|
var _buildWidget = async function(from_widget, target, mode, options, desc){
|
||||||
bricks.debug('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){
|
||||||
bricks.debug('options=', options, 'widgetBuild() failed');
|
bricks.debug('options=', options, 'widgetBuild() failed');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w.parent) return;
|
if (w.parent) return;
|
||||||
|
|
||||||
if (mode == 'replace'){
|
if (mode == 'replace'){
|
||||||
target.clear_widgets();
|
target.clear_widgets();
|
||||||
target.add_widget(w);
|
target.add_widget(w);
|
||||||
} else if (mode == 'insert'){
|
} else if (mode == 'insert'){
|
||||||
target.add_widget(w, 0);
|
target.add_widget(w, 0);
|
||||||
} else {
|
} else {
|
||||||
target.add_widget(w);
|
target.add_widget(w);
|
||||||
}
|
}
|
||||||
|
if ((target instanceof bricks.Popup || target instanceof bricks.PopupWindow) \
|
||||||
|
&& desc.popup_options.eventpos){
|
||||||
|
target.bind('opened', bricks.relocate_by_eventpos.bind(None, desc.event, target));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bricks.buildUrlwidgetHandler = function(w, target, rtdata, desc){
|
bricks.buildUrlwidgetHandler = function(w, target, rtdata, desc){
|
||||||
/*
|
|
||||||
var f = async function(target, mode, options){
|
|
||||||
bricks.debug('target=', target, 'mode=', mode, 'options=', options);
|
|
||||||
var w = await (bricks.widgetBuild(options, w));
|
|
||||||
if (!w){
|
|
||||||
bricks.debug('options=', options, 'widgetBuild() failed');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mode == 'replace'){
|
|
||||||
target.clear_widgets();
|
|
||||||
target.add_widget(w);
|
|
||||||
} else if (mode == 'insert'){
|
|
||||||
target.add_widget(w, 0);
|
|
||||||
} else {
|
|
||||||
target.add_widget(w);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
var options = objcopy(desc.options||{});
|
var options = objcopy(desc.options||{});
|
||||||
var params = options.params || {};
|
var params = options.params || {};
|
||||||
if (desc.event_params instanceof FormData){
|
if (desc.event_params instanceof FormData){
|
||||||
@ -352,27 +343,13 @@ bricks.buildUrlwidgetHandler = function(w, target, rtdata, desc){
|
|||||||
"widgettype":"urlwidget",
|
"widgettype":"urlwidget",
|
||||||
"options":options
|
"options":options
|
||||||
}
|
}
|
||||||
return _buildWidget.bind(w, target, target, desc.mode || 'replace', opts);
|
return _buildWidget.bind(None, w, target, desc.mode || 'replace', opts, desc);
|
||||||
}
|
}
|
||||||
bricks.buildBricksHandler = function(w, target, rtdata, desc){
|
bricks.buildBricksHandler = function(w, target, rtdata, desc){
|
||||||
/*
|
|
||||||
var f = async function(target, mode, options){
|
|
||||||
bricks.debug('target=', target, 'mode=', mode, 'options=', options);
|
|
||||||
var w = await (bricks.widgetBuild(options, wa));
|
|
||||||
if (!w){
|
|
||||||
bricks.debug('options=', options, 'widgetBuild() failed');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mode == 'replace'){
|
|
||||||
target.clear_widgets();
|
|
||||||
}
|
|
||||||
target.add_widget(w);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
var options = objcopy(desc.options||{});
|
var options = objcopy(desc.options||{});
|
||||||
rtdata = bricks.extend(rtdata, inputdata2dic(desc.event_params));
|
rtdata = bricks.extend(rtdata, inputdata2dic(desc.event_params));
|
||||||
options = bricks.apply_data(options, rtdata);
|
options = bricks.apply_data(options, rtdata);
|
||||||
return _buildWidget.bind(w, target, target, desc.mode || 'replace', options);
|
return _buildWidget.bind(w, target, target, desc.mode || 'replace', options, desc);
|
||||||
}
|
}
|
||||||
bricks.buildRegisterFunctionHandler = function(w, target, rtdata, desc){
|
bricks.buildRegisterFunctionHandler = function(w, target, rtdata, desc){
|
||||||
var f = bricks.RF.get(desc.rfname);
|
var f = bricks.RF.get(desc.rfname);
|
||||||
@ -449,7 +426,7 @@ bricks.getWidgetById = function(id, from_widget){
|
|||||||
el = bricks.app.root.dom_element;
|
el = bricks.app.root.dom_element;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ids[i]=='app'){
|
if (ids[i]=='app' || ids[i] == 'body'){
|
||||||
return bricks.app;
|
return bricks.app;
|
||||||
}
|
}
|
||||||
if (ids[i] == 'window'){
|
if (ids[i] == 'window'){
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
var bricks = window.bricks || {};
|
var bricks = window.bricks || {};
|
||||||
|
|
||||||
|
bricks.get_popup_default_options = function(){
|
||||||
|
return {
|
||||||
|
timeout:0,
|
||||||
|
archor:'cc',
|
||||||
|
auto_open:true,
|
||||||
|
auto_dismiss:true,
|
||||||
|
auto_destroy:true,
|
||||||
|
movable:true,
|
||||||
|
resizable:false,
|
||||||
|
modal:true
|
||||||
|
}
|
||||||
|
}
|
||||||
bricks.Popup = class extends bricks.VBox {
|
bricks.Popup = class extends bricks.VBox {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@ -52,13 +64,17 @@ bricks.Popup = class extends bricks.VBox {
|
|||||||
async load_content(){
|
async load_content(){
|
||||||
var w = await bricks.widgetBuild(this.content, this);
|
var w = await bricks.widgetBuild(this.content, this);
|
||||||
if (w){
|
if (w){
|
||||||
if (this.content.dismiss_event){
|
this.set_dismiss_events(w);
|
||||||
w.bind(this.content.dismiss_event, this.distroy.bind(this));
|
|
||||||
}
|
|
||||||
this.content_w.clear_widgets();
|
this.content_w.clear_widgets();
|
||||||
this.content_w.add_widget(w);
|
this.content_w.add_widget(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
set_dismiss_events(w){
|
||||||
|
if (!this.dismiss_events) return;
|
||||||
|
this.dismiss_events.forEach(ename => {
|
||||||
|
w.bind(ename, this.distroy.bind(this));
|
||||||
|
});
|
||||||
|
}
|
||||||
bring_to_top(){
|
bring_to_top(){
|
||||||
if (this == bricks.app.toppopup){
|
if (this == bricks.app.toppopup){
|
||||||
return;
|
return;
|
||||||
@ -324,23 +340,34 @@ bricks.Popup = class extends bricks.VBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_widget(w, i){
|
add_widget(w, i){
|
||||||
return this.content_box.add_widget(w, i);
|
this.set_dismiss_events(w);
|
||||||
|
return this.content_w.add_widget(w, i);
|
||||||
}
|
}
|
||||||
remove_widget(w){
|
remove_widget(w){
|
||||||
return this.content_box.remove_widget(w);
|
return this.content_w.remove_widget(w);
|
||||||
}
|
}
|
||||||
clear_widgets(){
|
clear_widgets(){
|
||||||
return this.content_box.clear_widgets();
|
return this.content_w.clear_widgets();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bricks.get_popupwindow_default_options = function(){
|
||||||
|
return {
|
||||||
|
timeout:0,
|
||||||
|
archor:'cc',
|
||||||
|
auto_open:true,
|
||||||
|
auto_dismiss:true,
|
||||||
|
auto_destroy:true,
|
||||||
|
movable:true,
|
||||||
|
resizable:true,
|
||||||
|
modal:true
|
||||||
|
}
|
||||||
|
}
|
||||||
bricks.PopupWindow = class extends bricks.Popup {
|
bricks.PopupWindow = class extends bricks.Popup {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
title:
|
title:
|
||||||
icon:
|
icon:
|
||||||
params:
|
|
||||||
url:
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
@ -354,11 +381,12 @@ bricks.PopupWindow = class extends bricks.Popup {
|
|||||||
this.auto_open = ao;
|
this.auto_open = ao;
|
||||||
this.title_bar = new bricks.HBox({css:'titlebar', cheight:2, width:'100%'});
|
this.title_bar = new bricks.HBox({css:'titlebar', cheight:2, width:'100%'});
|
||||||
this.moving_w = this.title_bar;
|
this.moving_w = this.title_bar;
|
||||||
super.add_widget(this.title_bar);
|
this.add_widget(this.title_bar);
|
||||||
this.build_title_bar();
|
this.build_title_bar();
|
||||||
var filler = new bricks.Filler({});
|
var filler = new bricks.Filler({});
|
||||||
super.add_widget(filler)
|
this.add_widget(filler)
|
||||||
this.content_w = new bricks.Layout({});
|
|
||||||
|
this.content_w = new bricks.Layout({height:'100%', width:'100%'});
|
||||||
this.content_w.set_css('flexbox');
|
this.content_w.set_css('flexbox');
|
||||||
filler.add_widget(this.content_w);
|
filler.add_widget(this.content_w);
|
||||||
if (this.auto_open){
|
if (this.auto_open){
|
||||||
|
@ -1,5 +1,29 @@
|
|||||||
var bricks = window.bricks || {};
|
var bricks = window.bricks || {};
|
||||||
bricks.bug = false;
|
bricks.bug = false;
|
||||||
|
|
||||||
|
var bricks.relocate_by_eventpos = function(event, widget){
|
||||||
|
var ex,ey;
|
||||||
|
var x,y;
|
||||||
|
var xsize = bricks.Body.dom_element.clientWidth;
|
||||||
|
var ysize = bricks.Body.dom_element.clientHeight;
|
||||||
|
ex = event.clientX;
|
||||||
|
ey = event.clientY;
|
||||||
|
var mxs = widget.dom_element.offsetWidth;
|
||||||
|
var mys = widget.dom_element.offsetHeight;
|
||||||
|
if (ex < (xsize / 2)) {
|
||||||
|
x = ex + bricks.app.charsize;
|
||||||
|
} else {
|
||||||
|
x = ex - mxs - bricks.app.charsize;
|
||||||
|
}
|
||||||
|
if (ey < (ysize / 2)) {
|
||||||
|
y = ey + bricks.app.charsize;
|
||||||
|
} else {
|
||||||
|
y = ey - mys - bricks.app.charsize;
|
||||||
|
}
|
||||||
|
widget.set_style('left', x + 'px');
|
||||||
|
widget.set_style('top', y + 'px');
|
||||||
|
}
|
||||||
|
|
||||||
var formdata2object = function(formdata){
|
var formdata2object = function(formdata){
|
||||||
let result = {};
|
let result = {};
|
||||||
formdata.forEach((value, key) => {
|
formdata.forEach((value, key) => {
|
||||||
|
@ -511,36 +511,22 @@ bricks.Tooltip = class extends bricks.Text {
|
|||||||
this.set_otext(otext);
|
this.set_otext(otext);
|
||||||
this.set_style('zIndex', 999999999);
|
this.set_style('zIndex', 999999999);
|
||||||
this.set_style('display', 'block');
|
this.set_style('display', 'block');
|
||||||
var ex,ey;
|
bricks.relocate_by_eventpos(event, this);
|
||||||
var x,y;
|
|
||||||
var xsize = bricks.Body.dom_element.clientWidth;
|
|
||||||
var ysize = bricks.Body.dom_element.clientHeight;
|
|
||||||
ex = event.clientX;
|
|
||||||
ey = event.clientY;
|
|
||||||
var mxs = this.dom_element.offsetWidth;
|
|
||||||
var mys = this.dom_element.offsetHeight;
|
|
||||||
if (ex < (xsize / 2)) {
|
|
||||||
x = ex + bricks.app.charsize;
|
|
||||||
} else {
|
|
||||||
x = ex - mxs - bricks.app.charsize;
|
|
||||||
}
|
|
||||||
if (ey < (ysize / 2)) {
|
|
||||||
y = ey + bricks.app.charsize;
|
|
||||||
} else {
|
|
||||||
y = ey - mys - bricks.app.charsize;
|
|
||||||
}
|
|
||||||
this.set_style('left', x + 'px');
|
|
||||||
this.set_style('top', y + 'px');
|
|
||||||
if (this.auto_task){
|
if (this.auto_task){
|
||||||
this.auto_task.cancel();
|
this.auto_task.cancel();
|
||||||
|
this.auto_task = null;
|
||||||
}
|
}
|
||||||
this.auto_task = schedule_once(this.hide.bind(this), 6);
|
this.auto_task = schedule_once(this.hide.bind(this), 6);
|
||||||
}
|
}
|
||||||
hide(){
|
hide(){
|
||||||
|
try {
|
||||||
if (this.auto_task){
|
if (this.auto_task){
|
||||||
this.auto_task.cancel();
|
this.auto_task.cancel();
|
||||||
this.auto_task = null;
|
this.auto_task = null;
|
||||||
}
|
}
|
||||||
|
} catch(e){
|
||||||
|
console.log('Exception:', e);
|
||||||
|
}
|
||||||
this.set_style('display', 'none');
|
this.set_style('display', 'none');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,14 @@ bricks的事件处理是在控件描述文件的binds区域中添加事件处理
|
|||||||
### dataparams
|
### dataparams
|
||||||
获取动态参数时需给定的参数, 可选,对象类型,k,v形式给定参数
|
获取动态参数时需给定的参数, 可选,对象类型,k,v形式给定参数
|
||||||
|
|
||||||
|
### popup_options
|
||||||
|
当target为“Popup“或“PopupWindow”时,定义Popup或PopupWindow的参数
|
||||||
|
|
||||||
|
#### dismiss_events
|
||||||
|
字符串数组,每个字符串定义一个Popup, PopupWindow的子控件的事件,这些事件发生时将导致Popup, PopupWindow关闭
|
||||||
|
|
||||||
|
#### eventpos
|
||||||
|
Popup, PopupWindow窗体移动到鼠标位置
|
||||||
|
|
||||||
### 获取动态参数说明
|
### 获取动态参数说明
|
||||||
绑定任务获取实时数据作为参数,需要给定以下属性:
|
绑定任务获取实时数据作为参数,需要给定以下属性:
|
||||||
@ -50,7 +58,15 @@ bricks的事件处理是在控件描述文件的binds区域中添加事件处理
|
|||||||
datamethod 优先datascript,从datawidget控件中通过datamethod
|
datamethod 优先datascript,从datawidget控件中通过datamethod
|
||||||
|
|
||||||
### target
|
### target
|
||||||
字符串或控件实例,目标控件实例,如果是字符串,使用”getWidgetById“函数获得目标控件实例,关于target规则请查看[控件id](widgetid.md)
|
支持一下形式的target定义:
|
||||||
|
* 目标控件实例对象
|
||||||
|
* 字符串,且等于“Popup“
|
||||||
|
* 字符串,且等于”PopupWindow“
|
||||||
|
* 其他字符串(控件对象的id)
|
||||||
|
当actiontype为"urlwidget"时,target应该是一个容器控件,所生成的控件将插入或替代到“target”所代表的对象中,如果actiontype是其他类型,则在此对象中执行方法,脚本,定义函数,或定义事件
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### conform
|
### conform
|
||||||
如果一个事件处理需要用户确认,可以在事件处理中指定一个conform属性来引发,当此事件发生时,会弹出一个确认窗口,用户确认后才会处理此事件,否则不处理
|
如果一个事件处理需要用户确认,可以在事件处理中指定一个conform属性来引发,当此事件发生时,会弹出一个确认窗口,用户确认后才会处理此事件,否则不处理
|
||||||
|
Loading…
Reference in New Issue
Block a user