Skip to content

Commit

Permalink
Bugs fixed for onInitPanelView
Browse files Browse the repository at this point in the history
  • Loading branch information
linb committed Nov 15, 2024
1 parent feb4e1a commit 38aa26e
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 67 deletions.
4 changes: 2 additions & 2 deletions API/App/js/xui-raw.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions runtime/xui/js/xui-all.js

Large diffs are not rendered by default.

74 changes: 43 additions & 31 deletions runtime/xui/js/xui-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -18121,6 +18121,10 @@ heightIncrement| | |
//for drag data
[dragKey]
[dragData]
-------------------------
onDragbegin
onDrag
onDragstop

profile output: readonly
===========================
Expand Down Expand Up @@ -18284,7 +18288,11 @@ xui.Class('xui.DragDrop',null,{
restrictedRight:NULL,
restrictedTop:NULL,
restrictedBottom:NULL,
dropElement:NULL
dropElement:NULL,

onDragbegin:NULL,
onDrag:NULL,
onDragstop:NULL
};
d.__touchingfordd=0;
return d;
Expand Down Expand Up @@ -18387,6 +18395,7 @@ xui.Class('xui.DragDrop',null,{

d.onDragBegin && d.onDragBegin();
d._source.onDragbegin();
p.onDragbegin && p.onDragbegin(xui.Event.getEventPara(e));
xui.tryF(d.DDBegin);

//set back first
Expand Down Expand Up @@ -18540,6 +18549,7 @@ xui.Class('xui.DragDrop',null,{
//d._source.onDrag(true); //shortcut for mousemove
}

p.onDrag && p.onDrag(xui.Event.getEventPara(e, _pos));
if(d._onDrag!=1){
if(d._onDrag)d._onDrag(e,d._source._get(0));
else{
Expand Down Expand Up @@ -18612,6 +18622,7 @@ xui.Class('xui.DragDrop',null,{
d.setDropFace();

var r = d._source.onDragstop(true,evt.getEventPara(e));
p.onDragstop && p.onDragstop(xui.Event.getEventPara(e));
if(d._dropElement)
xui.use(d._dropElement).onDrop(true,evt.getEventPara(e));
}
Expand Down Expand Up @@ -18957,15 +18968,8 @@ xui.Class('xui.DragDrop',null,{
}
function ondragenter(e) {
if(!e.relatedTarget){
var data = xui.unserialize(e.dataTransfer.getData('text/plain'));
if(data){
if(data.dragKey && data.dragData){
startXUIDD(data.dragKey, data.dragData);
}else{
console.log("No XUI DD dragKey or dragData in dataTransfer");
}
}else if(dd._xui_dragging_data){
data = dd._xui_dragging_data;
if(dd._xui_dragging_data){
var data = dd._xui_dragging_data;
if(data.dragKey && data.dragData){
startXUIDD(data.dragKey, data.dragData);
}else{
Expand Down Expand Up @@ -29531,7 +29535,7 @@ xui.Class("xui.UI.Div", "xui.UI",{

if(prop.iframeAutoLoad||prop.ajaxAutoLoad)
xui.UI.Div._applyAutoLoad(prf, item);
if(prf.onInitPanelView){
if(prf.onInitPanelView||prf.onIniPanelView){
var ins=prf.boxing(),
callback = function(obj){
if(xui.isStr(ojb)){
Expand All @@ -29543,7 +29547,7 @@ xui.Class("xui.UI.Div", "xui.UI",{
}else{
ins.append(obj, item && item.id);
}
}, obj = ins.onInitPanelView(prf, item && item.id, callback);
}, obj = (prf.onInitPanelView?ins.onInitPanelView:ins.onIniPanelView).apply(ins, [prf, item && item.id, callback]);
if(obj) callback(obj);
}
xui.UI.Div._for_svg_children(prf, item && item.id);
Expand Down Expand Up @@ -29585,11 +29589,11 @@ xui.Class("xui.UI.Div", "xui.UI",{
return data;
},
_applyAutoLoad:function(prf, item){
var subId = item && item.id, prop = item || prf.properties, ins=prf.boxing();
var subId = item && item.id, prop = item || prf.properties, ins=prf.boxing(), con=ins.getContainer(subId);
if(prop.iframeAutoLoad){
ins.getContainer(subId).css('overflow','hidden');
con.css('overflow','hidden');
var _if=typeof prop.iframeAutoLoad=='string'?{url:prop.iframeAutoLoad}:xui.clone(prop.iframeAutoLoad,true),
id="diframe_"+prf.$xid+"_"+(subId?(subId+"_"):"")+xui.rand(),
id="diframe_"+prf.$xid+"_"+xui.rand(),
e=xui.browser.ie && xui.browser.ver<9,
ifr=document.createElement(e?"<iframe name='"+id+"'>":"iframe");

Expand All @@ -29609,18 +29613,17 @@ xui.Class("xui.UI.Div", "xui.UI",{
ifr.allowTransparency='true';
ifr.width='100%';
ifr.height='100%';
ins.getContainer(subId).html("",false);
ins.append(ifr);
con.html("",false);

if((_if.method||"").toLowerCase()=="post"){
ins.append(ifr);
con.append(ifr);
xui.Dom.submit(_if.url, _if.query, "post", id, _if.enctype);
}else{
ifr.src=_if.url;
ins.append(ifr);
con.append(ifr);
}
if(prf.$afterAutoLoad)prf.$afterAutoLoad.call(prf.boxing(),prf);
if(prf.afterAutoLoad)prf.boxing().afterAutoLoad(prf,id);
if(prf.afterAutoLoad)prf.boxing().afterAutoLoad(prf,id,item);
}else if(prop.ajaxAutoLoad){
var _ajax=typeof prop.ajaxAutoLoad=='string'?{url:prop.ajaxAutoLoad}:xui.clone(prop.ajaxAutoLoad,true),
options={rspType:"text"};
Expand All @@ -29632,12 +29635,12 @@ xui.Class("xui.UI.Div", "xui.UI",{
xui.Ajax(xui.adjustRes(_ajax.url,false,true), _ajax.query, function(rsp){
node.html(rsp,true,true);
if(prf.$afterAutoLoad)prf.$afterAutoLoad.call(prf.boxing(),prf);
if(prf.afterAutoLoad)prf.boxing().afterAutoLoad(prf,rsp);
if(prf.afterAutoLoad)prf.boxing().afterAutoLoad(prf,rsp,item);
ins.free();
}, function(err){
node.html("<div>"+err+"</div>",true,false);
if(prf.$afterAutoLoad)prf.$afterAutoLoad.call(prf.boxing(),prf);
if(prf.afterAutoLoad)prf.boxing().afterAutoLoad(prf,rsp);
if(prf.afterAutoLoad)prf.boxing().afterAutoLoad(prf,rsp,item);
ins.free();
}, null, options).start();
}
Expand Down Expand Up @@ -30794,7 +30797,7 @@ xui.Class("xui.UI.Resizer","xui.UI",{
this.addTemplateKeys(['HANDLER','HIDDEN','MOVE','CONF1','CONF2','ROTATE','L','R','T','B','LT','RT','LB','RB','REGION']);
xui.each({
// add resizer to xui.Dom plugin
addResizer:function(properties, onUpdate, onChange){
addResizer:function(properties, onUpdate, onChange, onInit){
var target=xui([this.get(0)]);
properties=properties||{};
xui.merge(properties,{
Expand All @@ -30804,6 +30807,7 @@ xui.Class("xui.UI.Resizer","xui.UI",{
var r = new xui.UI.Resizer(properties)._attachTo(target, target);

//set event
if(onInit) r.onInit(onInit);
if(onUpdate) r.onUpdate(onUpdate);
if(onChange) r.onChange(onChange);
return r;
Expand Down Expand Up @@ -31255,7 +31259,7 @@ xui.Class("xui.UI.Resizer","xui.UI",{
// attached to a dom node for resizer function.
_attached:false,

//<< can be used in addResizer({*})
//<< can be used in addResizer({*})
// handler visible?
forceVisible:false,
// movable
Expand Down Expand Up @@ -31311,7 +31315,7 @@ xui.Class("xui.UI.Resizer","xui.UI",{
this.getSubNode('ROTATE').css('display',v?'':'none');
}
},
//>>
//>>

left: 100,
top: 100,
Expand All @@ -31323,8 +31327,9 @@ xui.Class("xui.UI.Resizer","xui.UI",{
},
EventHandlers:{
onDblclick:function(profile, e, src){},
onInit:function(profile, e, src, axis){},
onUpdate:function(profile, target, size, cssPos, rotate){},
onChange:function(profile, proxy){},
onChange:function(profile, proxy, args, offset){},
onConfig:function(profile, e, src,pos,type){}
},
_dynamicTemplate:function(profile){
Expand Down Expand Up @@ -31579,6 +31584,7 @@ xui.Class("xui.UI.Resizer","xui.UI",{
h = o.height(),
pos = o.offset(),
rotate;

if(rotatable){
rotate = o.rotate();
if(o.get(0).getBoundingClientRect){
Expand Down Expand Up @@ -31612,6 +31618,9 @@ xui.Class("xui.UI.Resizer","xui.UI",{
//set proxy to itself
profile.proxy = o;

if(profile.onInit && false===profile.boxing().onInit(profile, e, src, axis)){
return;
}

//get current w h from target
profile.o_w2 =profile.o_w =w;
Expand Down Expand Up @@ -31853,8 +31862,11 @@ xui.Class("xui.UI.Resizer","xui.UI",{
if(!data.transform)delete data.transform;
if(!xui.isEmpty(data)){
profile.proxy.css(data);
if(profile.onChange)
profile.boxing().onChange(profile,profile.proxy);
if(profile.onChange){
var r = profile.boxing().onChange(profile, profile.proxy, args, os);
if(r===false)
return;
}
var s = args.rotate ? (parseInt(rotate,10)+"°") : args.move? ((parseInt(data.left,10)-xOff) + " : " + (parseInt(data.top,10)-yOff)) : (parseInt(data.width||cs.width,10) + " X " + parseInt(data.height||cs.height,10));
xui.Tips.show(e,{tips:s});
}
Expand Down Expand Up @@ -43882,7 +43894,7 @@ xui.Class("xui.UI.Tabs", ["xui.UI", "xui.absList","xui.absValue"],{
afterItemClick:function(profile,item,e,src){},
onCaptionActive:function(profile, item,e,src){},
onClickPanel:function(profile, item, e, src){},
afterAutoLoad:function(profile, item, text){}
afterAutoLoad:function(profile, text, item){}
},
RenderTrigger:function(){
var self=this,v,i,ins;
Expand Down Expand Up @@ -48805,7 +48817,7 @@ xui.Class("xui.UI.Layout",["xui.UI", "xui.absList"],{
onDragResized:function(profile, item, size, e, src){},
onInitPanelView:function(profile, callback, id){},
onInitValues:function(profile, callback, id){},
afterAutoLoad:function(profile, item, text){}
afterAutoLoad:function(profile, text, item){}
},
_adjustItems2:function(items, pos){
var arr=[];
Expand Down Expand Up @@ -72120,7 +72132,7 @@ xui.Class("xui.svg.connector","xui.svg.absComb",{
conf = conf.split(":");
if(conf[1] && conf[1]!="KEY"){
prf = prf.getSubNode(conf[1], conf[2]);
return pf && prf.get(0);
return prf && prf.get(0);
}else{
return prf.getRootNode();
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/xui/js/xui.js

Large diffs are not rendered by default.

24 changes: 14 additions & 10 deletions xui/js/DragDrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ heightIncrement| | |
//for drag data
[dragKey]
[dragData]
-------------------------
onDragbegin
onDrag
onDragstop
profile output: readonly
===========================
Expand Down Expand Up @@ -288,7 +292,11 @@ xui.Class('xui.DragDrop',null,{
restrictedRight:NULL,
restrictedTop:NULL,
restrictedBottom:NULL,
dropElement:NULL
dropElement:NULL,

onDragbegin:NULL,
onDrag:NULL,
onDragstop:NULL
};
d.__touchingfordd=0;
return d;
Expand Down Expand Up @@ -391,6 +399,7 @@ xui.Class('xui.DragDrop',null,{

d.onDragBegin && d.onDragBegin();
d._source.onDragbegin();
p.onDragbegin && p.onDragbegin(xui.Event.getEventPara(e));
xui.tryF(d.DDBegin);

//set back first
Expand Down Expand Up @@ -544,6 +553,7 @@ xui.Class('xui.DragDrop',null,{
//d._source.onDrag(true); //shortcut for mousemove
}

p.onDrag && p.onDrag(xui.Event.getEventPara(e, _pos));
if(d._onDrag!=1){
if(d._onDrag)d._onDrag(e,d._source._get(0));
else{
Expand Down Expand Up @@ -616,6 +626,7 @@ xui.Class('xui.DragDrop',null,{
d.setDropFace();

var r = d._source.onDragstop(true,evt.getEventPara(e));
p.onDragstop && p.onDragstop(xui.Event.getEventPara(e));
if(d._dropElement)
xui.use(d._dropElement).onDrop(true,evt.getEventPara(e));
}
Expand Down Expand Up @@ -961,15 +972,8 @@ xui.Class('xui.DragDrop',null,{
}
function ondragenter(e) {
if(!e.relatedTarget){
var data = xui.unserialize(e.dataTransfer.getData('text/plain'));
if(data){
if(data.dragKey && data.dragData){
startXUIDD(data.dragKey, data.dragData);
}else{
console.log("No XUI DD dragKey or dragData in dataTransfer");
}
}else if(dd._xui_dragging_data){
data = dd._xui_dragging_data;
if(dd._xui_dragging_data){
var data = dd._xui_dragging_data;
if(data.dragKey && data.dragData){
startXUIDD(data.dragKey, data.dragData);
}else{
Expand Down
23 changes: 11 additions & 12 deletions xui/js/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -9432,7 +9432,7 @@ xui.Class("xui.UI.Div", "xui.UI",{

if(prop.iframeAutoLoad||prop.ajaxAutoLoad)
xui.UI.Div._applyAutoLoad(prf, item);
if(prf.onInitPanelView){
if(prf.onInitPanelView||prf.onIniPanelView){
var ins=prf.boxing(),
callback = function(obj){
if(xui.isStr(ojb)){
Expand All @@ -9444,7 +9444,7 @@ xui.Class("xui.UI.Div", "xui.UI",{
}else{
ins.append(obj, item && item.id);
}
}, obj = ins.onInitPanelView(prf, item && item.id, callback);
}, obj = (prf.onInitPanelView?ins.onInitPanelView:ins.onIniPanelView).apply(ins, [prf, item && item.id, callback]);
if(obj) callback(obj);
}
xui.UI.Div._for_svg_children(prf, item && item.id);
Expand Down Expand Up @@ -9486,11 +9486,11 @@ xui.Class("xui.UI.Div", "xui.UI",{
return data;
},
_applyAutoLoad:function(prf, item){
var subId = item && item.id, prop = item || prf.properties, ins=prf.boxing();
var subId = item && item.id, prop = item || prf.properties, ins=prf.boxing(), con=ins.getContainer(subId);
if(prop.iframeAutoLoad){
ins.getContainer(subId).css('overflow','hidden');
con.css('overflow','hidden');
var _if=typeof prop.iframeAutoLoad=='string'?{url:prop.iframeAutoLoad}:xui.clone(prop.iframeAutoLoad,true),
id="diframe_"+prf.$xid+"_"+(subId?(subId+"_"):"")+xui.rand(),
id="diframe_"+prf.$xid+"_"+xui.rand(),
e=xui.browser.ie && xui.browser.ver<9,
ifr=document.createElement(e?"<iframe name='"+id+"'>":"iframe");

Expand All @@ -9510,18 +9510,17 @@ xui.Class("xui.UI.Div", "xui.UI",{
ifr.allowTransparency='true';
ifr.width='100%';
ifr.height='100%';
ins.getContainer(subId).html("",false);
ins.append(ifr);
con.html("",false);

if((_if.method||"").toLowerCase()=="post"){
ins.append(ifr);
con.append(ifr);
xui.Dom.submit(_if.url, _if.query, "post", id, _if.enctype);
}else{
ifr.src=_if.url;
ins.append(ifr);
con.append(ifr);
}
if(prf.$afterAutoLoad)prf.$afterAutoLoad.call(prf.boxing(),prf);
if(prf.afterAutoLoad)prf.boxing().afterAutoLoad(prf,id);
if(prf.afterAutoLoad)prf.boxing().afterAutoLoad(prf,id,item);
}else if(prop.ajaxAutoLoad){
var _ajax=typeof prop.ajaxAutoLoad=='string'?{url:prop.ajaxAutoLoad}:xui.clone(prop.ajaxAutoLoad,true),
options={rspType:"text"};
Expand All @@ -9533,12 +9532,12 @@ xui.Class("xui.UI.Div", "xui.UI",{
xui.Ajax(xui.adjustRes(_ajax.url,false,true), _ajax.query, function(rsp){
node.html(rsp,true,true);
if(prf.$afterAutoLoad)prf.$afterAutoLoad.call(prf.boxing(),prf);
if(prf.afterAutoLoad)prf.boxing().afterAutoLoad(prf,rsp);
if(prf.afterAutoLoad)prf.boxing().afterAutoLoad(prf,rsp,item);
ins.free();
}, function(err){
node.html("<div>"+err+"</div>",true,false);
if(prf.$afterAutoLoad)prf.$afterAutoLoad.call(prf.boxing(),prf);
if(prf.afterAutoLoad)prf.boxing().afterAutoLoad(prf,rsp);
if(prf.afterAutoLoad)prf.boxing().afterAutoLoad(prf,rsp,item);
ins.free();
}, null, options).start();
}
Expand Down
2 changes: 1 addition & 1 deletion xui/js/UI/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ xui.Class("xui.UI.Layout",["xui.UI", "xui.absList"],{
onDragResized:function(profile, item, size, e, src){},
onInitPanelView:function(profile, callback, id){},
onInitValues:function(profile, callback, id){},
afterAutoLoad:function(profile, item, text){}
afterAutoLoad:function(profile, text, item){}
},
_adjustItems2:function(items, pos){
var arr=[];
Expand Down
Loading

0 comments on commit 38aa26e

Please sign in to comment.