Skip to content

Commit a002dbe

Browse files
committed
Enhanced alias
1 parent e008151 commit a002dbe

31 files changed

+757
-359
lines changed

API/App/js/xui-raw.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runtime/xui/js/Module/JSONEditor.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
xui.Class('xui.Module.JSONEditor', 'xui.Module',{
22
Instance:{
33
activate:function(){},
4+
_oldvalue:{},
45
setValue:function(str, keyOptions){
56
var ns=this,
67
obj=xui.isStr(str)?str?xui.unserialize(str):false:str,
@@ -11,6 +12,7 @@ xui.Class('xui.Module.JSONEditor', 'xui.Module',{
1112
ns.tg.updateHeader("key",{type:'input',editorListItems: null});
1213
}
1314
ns.tg.setRows(rows).free();
15+
ns._oldvalue = obj||{};
1416
},
1517
getValue:function(returnObj){
1618
var rows=this.tg.getRows();
@@ -20,6 +22,9 @@ xui.Class('xui.Module.JSONEditor', 'xui.Module',{
2022
getEditor:function(){
2123
return this.tg;
2224
},
25+
checkDirty:function(){
26+
return !xui.deepEquals(this._oldvalue, this.getValue(true));
27+
},
2328
iniComponents:function(){
2429
// [[Code created by CrossUI RAD Studio
2530
var host=this, children=[], append=function(child){children.push(child.get(0));};
@@ -355,6 +360,9 @@ xui.Class('xui.Module.JSONEditor', 'xui.Module',{
355360
case "add2":
356361
nid=xui.stamp();
357362
tg.insertRows([{id:nid, cells:[{value:type=='array'?'[index]':ns.getDefaultKey(),readonly:type=='array'},'null','']}]);
363+
if(tg.getRows().length===1){
364+
tg.adjustRelWith();
365+
}
358366
break;
359367
case 'up':
360368
nid=xui.stamp();
@@ -366,7 +374,10 @@ xui.Class('xui.Module.JSONEditor', 'xui.Module',{
366374
break;
367375
case 'del':
368376
// xui.confirm('confirm','Do you want to delete this node?',function(){
369-
tg.removeRows([row.id]);
377+
tg.removeRows([row.id]);
378+
if(tg.getRows().length===0){
379+
tg.adjustRelWith();
380+
}
370381
// });
371382
break;
372383
}

runtime/xui/js/xui-all.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runtime/xui/js/xui-debug.js

+365-177
Large diffs are not rendered by default.

runtime/xui/js/xui.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xui/js/APICaller.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ xui.Class("xui.APICaller","xui.absObj",{
393393
},
394394
Static:{
395395
WDSLCache:{},
396-
$nameTag:"api_",
396+
$nameTag:"api",
397397
timeout: 60000,
398398
_pool:{},
399399
_objectProp:{tagVar:1,propBinder:1,queryArgs:1,queryData:1,queryHeader:1,queryOptions:1,fakeCookies:1,requestDataSource:1,responseDataTarget:1,responseCallback:1},

xui/js/DataBinder.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ xui.Class("xui.DataBinder","xui.absObj",{
1212
profile.__gc();
1313
});
1414
},
15-
setHost:function(value, alias){
15+
setHost:function(value, alias, ref){
1616
var self=this;
1717
if(value && alias)
1818
self.setName(alias);
@@ -389,7 +389,7 @@ xui.Class("xui.DataBinder","xui.absObj",{
389389
}
390390
},
391391
Static:{
392-
$nameTag:"databinder_",
392+
$nameTag:"databinder",
393393
_pool:{},
394394
_objectProp:{tagVar:1,propBinder:1,data:1},
395395
destroyAll:function(){

xui/js/Dom.js

+20-21
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,22 @@ xui.Class('xui.Dom','xui.absBox',{
317317
},target,reversed);
318318
},
319319
contains:function(node){
320-
var c = this.get(0);
321-
if(c.contains)return c.contains(node);
322-
else{
323-
while(node=node.parentNode){
324-
if(node==c)return true;
320+
var con=false;
321+
this.each(function(c){
322+
if(c.contains && c.contains(node)){
323+
con = true;
324+
}else{
325+
var _n=node;
326+
while(_n=_n.parentNode){
327+
if(_n==c){
328+
con = true;
329+
break;
330+
}
331+
}
325332
}
326-
return false;
327-
}
333+
if(con)return false;
334+
});
335+
return con;
328336
},
329337
//flag: false => no remove this from momery(IE)
330338
replace:function(target, triggerGC){
@@ -2071,8 +2079,7 @@ xui.Class('xui.Dom','xui.absBox',{
20712079
},
20722080

20732081
//for remove obj when blur
2074-
setBlurTrigger : function(id, trigger/*[false] for anti*/, group /*keep the original refrence*/,
2075-
/*two inner params */ checkChild, triggerNext){
2082+
setBlurTrigger : function(id, trigger/*[false] for anti*/, group /*keep the original refrence*/,triggerNext/*check next? */){
20762083
var ns=this,
20772084
doc=document,
20782085
sid='$blur_triggers$',
@@ -2102,15 +2109,10 @@ xui.Class('xui.Dom','xui.absBox',{
21022109
if(!v)return;
21032110

21042111
b=true;
2105-
var isChild=function(){
2106-
var nds=v.target.get();
2107-
while (srcN && srcN.nodeName && srcN.nodeName!="BODY" && srcN.nodeName!="HTML"){
2108-
if(xui.arr.indexOf(nds,srcN)!=-1)
2109-
return true;
2110-
srcN = srcN.parentNode;
2111-
}
2112-
};
2113-
if(!v.checkChild || isChild()){
2112+
// if child, do not trigger
2113+
if(v.target.contains(srcN)){
2114+
b=false;
2115+
}else{
21142116
v.target.each(function(o){
21152117
if(o.parentNode && (w=o.offsetParent?o.offsetWidth:0) && (h=o.offsetParent?o.offsetHeight:0)){
21162118
pos=xui([o]).offset();
@@ -2121,8 +2123,6 @@ xui.Class('xui.Dom','xui.absBox',{
21212123
});
21222124
}
21232125

2124-
isChild=null;
2125-
21262126
// anti trigger
21272127
if(!b && !xui.isFun(v.trigger))
21282128
return false;
@@ -2173,7 +2173,6 @@ xui.Class('xui.Dom','xui.absBox',{
21732173
arr[id]={
21742174
trigger:trigger,
21752175
target:target,
2176-
checkChild:!!checkChild,
21772176
stopNext:!triggerNext
21782177
};
21792178
arr.push(id);

xui/js/DragDrop.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ xui.Class('xui.DragDrop',null,{
363363
var fromN=xui.Event.getSrc(e);
364364

365365
d._start=function(e){
366-
//ie6: mousemove - mousedown =>78 ms
367-
//delay is related to window size, weird
368-
// try{
366+
//ie6: mousemove - mousedown =>78 ms
367+
//delay is related to window size, weird
368+
// try{
369369
var p=d._profile;
370370
//set profile
371371
xui.merge(p, profile, "with");
@@ -389,6 +389,7 @@ xui.Class('xui.DragDrop',null,{
389389
// on scrollbar
390390
if(profile.x >= d._box.width || profile.y >= d._box.height ){d._end()._reset();return true}
391391

392+
d.onDragBegin && d.onDragBegin();
392393
d._source.onDragbegin();
393394

394395
//set back first
@@ -443,7 +444,7 @@ xui.Class('xui.DragDrop',null,{
443444
});
444445
}
445446
}
446-
// }catch(e){d._end()._reset();}
447+
// }catch(e){d._end()._reset();}
447448
};
448449
if(xui.browser.ie){
449450
d.$ondragstart=doc.ondragstart;
@@ -455,7 +456,7 @@ xui.Class('xui.DragDrop',null,{
455456

456457
//fire document onmousedown event
457458
if(profile.targetNode.get(0)!==doc)
458-
xui(doc).onMousedown(true, xui.Event.getEventPara(e, _pos));
459+
profile.targetNode.onMousedown(true, xui.Event.getEventPara(e, _pos));
459460

460461
if(profile.dragDefer<1){
461462
xui.tryF(d._start,[e],d);

xui/js/Module.js

+27-17
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ xui.Class('xui.Module','xui.absProfile',{
3232
var ns=this;
3333
xui.launch = function(cls, onEnd, lang, theme, showUI, parent, subId, onCreated, onDomReady){
3434
ns.load.apply(ns, [cls, function(err, module){
35-
if(module)module.setHost(window, xui.ini.rootModuleName);
35+
if(xui.ini.rootModuleName) window[xui.ini.rootModuleName] = module;
3636
xui.tryF(onEnd, [err, module], module);
3737
}, lang, theme, showUI, parent, subId, onCreated, onDomReady]);
3838
};
@@ -81,12 +81,12 @@ xui.Class('xui.Module','xui.absProfile',{
8181
// events for instance
8282
e.events={};
8383
}
84-
self._nameId=0;
85-
self._nameTag=self.$nameTag||(self.KEY.replace(/\./g,'_').toLowerCase());
84+
self._nameId=self._refId=0;
85+
self._nameTag=self.$nameTag||(self.KEY.replace("xui.",'').replace(/\./g,'_').toLowerCase());
8686
self._cache=[];
8787
},
8888
Constructor:function(properties, events, host){
89-
var self=this,opt,alias,t;
89+
var self=this,opt,alias,ref,t;
9090

9191
// If it's a older module object, set xid first
9292
if(properties && properties.constructor==self.constructor){
@@ -105,6 +105,7 @@ xui.Class('xui.Module','xui.absProfile',{
105105

106106
events = oldm.events || {};
107107
alias = oldm.alias;
108+
ref = oldm.ref;
108109
host = oldm.host;
109110
properties = oldm.properties || {};
110111
// for refresh , use the old pointer
@@ -115,6 +116,7 @@ xui.Class('xui.Module','xui.absProfile',{
115116
properties = (opt && opt.properties) || {};
116117
events = (opt && opt.events) || {};
117118
alias = opt.alias;
119+
ref = opt.ref;
118120
host = opt.host;
119121
}else{
120122
if(!properties){
@@ -133,24 +135,21 @@ xui.Class('xui.Module','xui.absProfile',{
133135
self.box=self.constructor;
134136
self.key=self.KEY;
135137

136-
if(!alias)alias =self.constructor.pickAlias();
137138
if(!xui.isEmpty(self.constructor.$DataModel)){
138139
xui.merge( properties, xui.clone(self.constructor.$DataModel),'without');
139140
}
140141
//
141142
self._links={};
142-
self.link(self.constructor._cache, "self");
143-
self.link(xui.Module._cache, "xui.module");
144-
self.link(xui._pool,'xui');
143+
self.link(self.constructor._cache, "self").link(xui.Module._cache, "xui.module");
145144

146145
self.host=host||self;
147146
self.alias=alias;
147+
self.ref=ref;
148148
self.container = null;
149149

150150
self.$UIvalue="";
151151

152152
self._nodes=[];
153-
self._ctrlpool={};
154153
self.events=events;
155154
self.properties={};
156155
self.hooks={};
@@ -262,8 +261,8 @@ xui.Class('xui.Module','xui.absProfile',{
262261
getContainer:function(){
263262
return this.container;
264263
},
265-
setHost:function(host, alias){
266-
return xui.absObj.prototype._setHostAlias.call(this, host, alias);
264+
setHost:function(host, alias, ref){
265+
return xui.absObj.prototype._setHostAlias.call(this, host, alias, ref);
267266
},
268267
getName:function(){
269268
return this.properties.name || this.alias;
@@ -437,6 +436,7 @@ xui.Class('xui.Module','xui.absProfile',{
437436
key:o.KEY,
438437
host:o.host
439438
};
439+
if(o.ref)r.ref=o.ref;
440440
//host
441441
if(r.host===self){
442442
delete r.host;
@@ -482,6 +482,7 @@ xui.Class('xui.Module','xui.absProfile',{
482482
clone:function(){
483483
var ns=this.serialize(false,true);
484484
delete ns.alias;
485+
delete ns.ref;
485486
return this.constructor.unserialize(ns);
486487
},
487488
// for outter events
@@ -616,6 +617,7 @@ xui.Class('xui.Module','xui.absProfile',{
616617
box=o.box,
617618
host=o.host,
618619
alias=o.alias,
620+
ref=o.ref,
619621
$xid=o.$xid,
620622
hashIn=o._render_conf,
621623
pPrf=o._render_holder,
@@ -659,7 +661,7 @@ xui.Class('xui.Module','xui.absProfile',{
659661

660662
//create, must keep the original refrence pointer
661663
new box(o);
662-
if(host)o.setHost(host,alias);
664+
if(host)o.setHost(host,alias,ref);
663665

664666
// must here
665667
o.moduleClass=mcls;
@@ -1324,7 +1326,7 @@ xui.Class('xui.Module','xui.absProfile',{
13241326
AddComponents:function(obj){
13251327
var self=this;
13261328
xui.arr.each(obj.get(),function(o){
1327-
o.boxing().setHost(self, o.alias);
1329+
o.boxing().setHost(self, o.alias, o.ref);
13281330
self._nodes.push(o);
13291331
xui.Module.$attachModuleInfo(self,o);
13301332
});
@@ -1337,9 +1339,14 @@ xui.Class('xui.Module','xui.absProfile',{
13371339
var self=this,con=self.constructor,ns=self._nodes;
13381340
if(self.destroyed)return;
13391341

1342+
13401343
self._fireEvent('onDestroy');
13411344
if(self.alias && self.host && self.host[self.alias]){
1342-
try{delete self.host[self.alias]}catch(e){self.host[self.alias]=null}
1345+
try{if(self.alias in self.host)delete self.host[self.alias];}catch(e){self.host[self.alias]=void(0)}
1346+
if(self.host._ctrlpool && (self.alias in self.host._ctrlpool))delete self.host._ctrlpool[self.alias];
1347+
}
1348+
if(self.ref && self.host && self.host[self.ref]){
1349+
try{if(self.ref in self.host)delete self.host[self.ref];}catch(e){self.host[self.ref]=void(0)}
13431350
}
13441351

13451352
//set once
@@ -1352,9 +1359,8 @@ xui.Class('xui.Module','xui.absProfile',{
13521359

13531360
if(ns && ns.length)
13541361
self._nodes.length=0;
1355-
self._ctrlpool=null;
13561362

1357-
self.unLinkAll();
1363+
xui.absProfile.prototype.__gc.call(this);
13581364

13591365
if(!keepStructure){
13601366
xui.breakO(self);
@@ -1387,7 +1393,8 @@ xui.Class('xui.Module','xui.absProfile',{
13871393
var m=this,keep={
13881394
'$children':m.$children,
13891395
_cache:m._cache,
1390-
_nameId:m._nameId
1396+
_nameId:m._nameId,
1397+
_refId:m._refId
13911398
},
13921399
key=m.KEY,
13931400
path=key.split("."),
@@ -1414,6 +1421,9 @@ xui.Class('xui.Module','xui.absProfile',{
14141421
pickAlias:function(){
14151422
return xui.absObj.$pickAlias(this);
14161423
},
1424+
pickRef:function(){
1425+
return xui.absObj.$pickRef(this);
1426+
},
14171427
getFromDom:function(id){
14181428
var prf=xui.UIProfile.getFromDom(id);
14191429
if(prf&&(prf=prf.host)){

0 commit comments

Comments
 (0)