Skip to content

Commit

Permalink
Separate ref to _ref_pool
Browse files Browse the repository at this point in the history
  • Loading branch information
linb committed Oct 18, 2024
1 parent 92faa7f commit 1f1cf48
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 103 deletions.
2 changes: 1 addition & 1 deletion API/App/js/xui-raw.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion runtime/xui/js/xui-all.js

Large diffs are not rendered by default.

126 changes: 72 additions & 54 deletions runtime/xui/js/xui-debug.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion runtime/xui/js/xui.js

Large diffs are not rendered by default.

39 changes: 20 additions & 19 deletions xui/js/Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ xui.Class('xui.Module','xui.absProfile',{
cellsMap={},
cell2alias = {}, alias2cell={};
if(formula){
xui.each(this._ctrlpool, function(prf){
xui.each(this._alias_pool, function(prf){
var p = prf.properties,t;
if((t=p.excelCellId) && /^\s*[a-zA-Z]+[\d]+\s*$/.test(t)){
cell2alias[t]=prf.alias;
Expand Down Expand Up @@ -920,7 +920,7 @@ xui.Class('xui.Module','xui.absProfile',{
rowMax = 0, colMax = 0,
cellId = profileFrom && profileFrom.alias;
//1. collection all formula cells
xui.each(this._ctrlpool, function(prf){
xui.each(this._alias_pool, function(prf){
var p = prf.properties,t;
if(t=p.excelCellFormula){
formulaCells[prf.alias]=[prf,t];
Expand Down Expand Up @@ -1003,7 +1003,7 @@ xui.Class('xui.Module','xui.absProfile',{
if(!this._innerModulesCreated)this._createInnerModules();

var hash={},t;
xui.each(this._ctrlpool, function(prf){
xui.each(this._alias_pool, function(prf){
t=hash[prf.alias]=prf.serialize(false,false,false);
delete t.key;
delete t.alias;
Expand All @@ -1015,7 +1015,7 @@ xui.Class('xui.Module','xui.absProfile',{
setProfile:function(profiles){
if(!this._innerModulesCreated)this._createInnerModules();

xui.each(this._ctrlpool, function(prf,i){
xui.each(this._alias_pool, function(prf,i){
if(prf.alias in profiles){
i=profiles[prf.alias];
var ins=prf.boxing();
Expand All @@ -1042,7 +1042,7 @@ xui.Class('xui.Module','xui.absProfile',{
var hash={};
try{
scope_set.call(this);
xui.each(this._ctrlpool, function(prf){
xui.each(this._alias_pool, function(prf){
var prop=prf.properties;
if(prop.propBinder)
xui.each(prop.propBinder,function(fun,key){
Expand All @@ -1067,7 +1067,7 @@ xui.Class('xui.Module','xui.absProfile',{

try{
scope_set.call(this, dataMap);
xui.each(this._ctrlpool, function(prf){
xui.each(this._alias_pool, function(prf){
prf.boxing().reBindProp(dataMap,scope_set,scope_clear, true);
});
}catch(e){
Expand All @@ -1078,7 +1078,7 @@ xui.Class('xui.Module','xui.absProfile',{
if(!this._innerModulesCreated)this._createInnerModules();

var hash={};
xui.each(this._ctrlpool, function(prf){
xui.each(this._alias_pool, function(prf){
var prop=prf.properties,
ins=prf.boxing(),
ih=hash[prf.alias]={};
Expand All @@ -1096,7 +1096,7 @@ xui.Class('xui.Module','xui.absProfile',{
setData:function(data){
if(!this._innerModulesCreated)this._createInnerModules();

xui.each(this._ctrlpool, function(prf){
xui.each(this._alias_pool, function(prf){
var prop=prf.properties,
ins=prf.boxing(),ih;
if(prf.alias in data){
Expand All @@ -1118,7 +1118,7 @@ xui.Class('xui.Module','xui.absProfile',{
if(!this._innerModulesCreated)this._createInnerModules();

var hash={}, cap, uv;
xui.each(this._ctrlpool, function(prf){
xui.each(this._alias_pool, function(prf){
if('value' in prf.properties){
if(xui.isSet(prf.properties.caption)){
cap = prf.properties.caption;
Expand All @@ -1145,7 +1145,7 @@ xui.Class('xui.Module','xui.absProfile',{
if(!this._innerModulesCreated)this._createInnerModules();

if(!xui.isEmpty(values)){
xui.each(this._ctrlpool, function(prf){
xui.each(this._alias_pool, function(prf){
if('value' in prf.properties && prf.alias in values){
var v=values[prf.alias],b=xui.isHash(v) ;
prf.boxing().setValue((b && ('value' in v)) ? v.value : v, true,'module');
Expand All @@ -1164,7 +1164,7 @@ xui.Class('xui.Module','xui.absProfile',{
if(!this._innerModulesCreated)this._createInnerModules();

var hash={};
xui.each(this._ctrlpool, function(prf){
xui.each(this._alias_pool, function(prf){
if('$UIvalue' in prf.properties)
hash[prf.alias]=prf.properties.$UIvalue;
});
Expand All @@ -1178,7 +1178,7 @@ xui.Class('xui.Module','xui.absProfile',{
if(!this._innerModulesCreated)this._createInnerModules();

if(!xui.isEmpty(values)){
xui.each(this._ctrlpool, function(prf){
xui.each(this._alias_pool, function(prf){
if('value' in prf.properties && prf.alias in values){
var v=values[prf.alias],b=xui.isHash(v) ;
prf.boxing().setUIValue((b && ('value' in v))?v.value:v, true,false,'module');
Expand All @@ -1195,7 +1195,7 @@ xui.Class('xui.Module','xui.absProfile',{
resetValue:function(innerUI){
if(innerUI){
if(!this._innerModulesCreated)this._createInnerModules();
xui.each(this._ctrlpool, function(prf){
xui.each(this._alias_pool, function(prf){
if(prf.boxing().resetValue)prf.boxing().resetValue();
});
}else{
Expand All @@ -1206,7 +1206,7 @@ xui.Class('xui.Module','xui.absProfile',{
updateValue:function(innerUI){
if(innerUI){
if(!this._innerModulesCreated)this._createInnerModules();
xui.each(this._ctrlpool, function(prf){
xui.each(this._alias_pool, function(prf){
if(prf.boxing().updateValue)prf.boxing().updateValue();
});
}else{
Expand All @@ -1220,7 +1220,7 @@ xui.Class('xui.Module','xui.absProfile',{
if(!this._innerModulesCreated)this._createInnerModules();

var dirtied=false;
xui.each(this._ctrlpool, function(prf){
xui.each(this._alias_pool, function(prf){
if(prf.boxing().isDirtied){
if(prf.boxing().isDirtied()){
return false;
Expand All @@ -1236,7 +1236,7 @@ xui.Class('xui.Module','xui.absProfile',{
if(innerUI){
if(!this._innerModulesCreated)this._createInnerModules();

xui.each(this._ctrlpool, function(prf){
xui.each(this._alias_pool, function(prf){
if(prf.boxing().checkValid){
if(!prf.boxing().checkValid()){
return false;
Expand All @@ -1260,7 +1260,7 @@ xui.Class('xui.Module','xui.absProfile',{
getForms:function(){
if(!this._innerModulesCreated)this._createInnerModules();

var nodes = xui.copy(this._ctrlpool),t,k='xui.absContainer';
var nodes = xui.copy(this._alias_pool),t,k='xui.absContainer';
xui.filter(nodes,function(o){
return !!(o.box[k]);
});
Expand All @@ -1272,7 +1272,7 @@ xui.Class('xui.Module','xui.absProfile',{
var nodes=[];
var fun = function(m){
if(m["xui.Module"]){
xui.each(m._ctrlpool,function(o){
xui.each(m._alias_pool,function(o){
if(o["xui.Module"])fun(o);
else nodes.push(o);
});
Expand Down Expand Up @@ -1343,10 +1343,11 @@ xui.Class('xui.Module','xui.absProfile',{
self._fireEvent('onDestroy');
if(self.alias && self.host && self.host[self.alias]){
try{if(self.alias in self.host)delete self.host[self.alias];}catch(e){self.host[self.alias]=void(0)}
if(self.host._ctrlpool && (self.alias in self.host._ctrlpool))delete self.host._ctrlpool[self.alias];
if(self.host._alias_pool && (self.alias in self.host._alias_pool))delete self.host._alias_pool[self.alias];
}
if(self.ref && self.host && self.host[self.ref]){
try{if(self.ref in self.host)delete self.host[self.ref];}catch(e){self.host[self.ref]=void(0)}
if(self.host._ref_pool && (self.ref in self.host._ref_pool))delete self.host._ref_pool[self.ref];
}

//set once
Expand Down
24 changes: 18 additions & 6 deletions xui/js/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,11 @@ xui.Class('xui.UIProfile','xui.Profile', {
var o;
if(ns.alias && ns.host && (o=ns.host[ns.alias]) && (o=o._nodes) && (o.length===0 || o.length===1 && o[0]==ns)){
try{if(ns.alias in ns.host)delete ns.host[ns.alias];}catch(e){ns.host[ns.alias]=void(0)}
if(ns.host._ctrlpool && (ns.alias in ns.host._ctrlpool))delete ns.host._ctrlpool[ns.alias];
if(ns.host._alias_pool && (ns.alias in ns.host._alias_pool))delete ns.host._alias_pool[ns.alias];
}
if(ns.ref && ns.host && (o=ns.host[ns.ref]) && (o=o._nodes) && (o.length===0 || o.length===1 && o[0]==ns)){
try{if(ns.ref in ns.host)delete ns.host[ns.ref];}catch(e){ns.host[ns.ref]=void(0)}
if(ns.host._ref_pool && (ns.ref in ns.host._ref_pool))delete ns.host._ref_pool[ns.ref];
}
//clear anti link
ns.unLinkAll();
Expand Down Expand Up @@ -2227,6 +2228,7 @@ xui.Class("xui.UI", "xui.absObj", {
//invalid after dom dom Node
zIndex:{
ini:1,
precision:0,
action:function(value){
this.getRoot().css('zIndex',value);
}
Expand Down Expand Up @@ -8729,6 +8731,7 @@ xui.Class("xui.UI.HTMLButton", "xui.UI.Element",{
},
DataModel:{
nodeName:null,

tabindex:1,
width:'auto',
height:'auto',
Expand Down Expand Up @@ -9506,6 +9509,8 @@ xui.Class("xui.UI.CSSBox","xui.UI.Span",{
onResize:null,
onShowTips:null,
beforeHoverEffect:null,
beforeHoverHide:null,
beforeHoverPop:null,
beforeAppend:null,
afterAppend:null,
beforeRender:null,
Expand Down Expand Up @@ -9676,15 +9681,22 @@ xui.Class("xui.UI.ModulePlaceHolder", "xui.UI",{
RenderTrigger:function(){
var prf=this;
if(prf.$inDesign)return;

var created;
if(prf && !prf._replaced && (prf._module||prf.properties.moduleName)){
if(!prf._module){
prf._module = xui.create(prf.properties.moduleName, "xui.Module");
prf.boxing().detachHost();
prf._module.setHost(prf.host, prf.alias, prf.ref);
prf._module.module_container = prf.getParent();
if(prf._module.KEY == prf.properties.moduleName){
prf.boxing().detachHost();
prf._module.setHost(prf.host, prf.alias, prf.ref);
prf._module.module_container = prf.getParent();
created=1;
}
}
if(created){
prf.boxing().replaceWithModule(prf._module);
}else if(xui.debugMode){
prf.getRoot().css('display', 'block');
}
prf.boxing().replaceWithModule(prf._module);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions xui/js/UI/Gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,14 @@ xui.Class("xui.UI.Gallery", "xui.UI.List",{
},
itemWidth:{
$spaceunit:1,
ini:32,
ini:'32px',
action:function(v){
this.boxing().refresh();
}
},
itemHeight:{
$spaceunit:1,
ini:32,
ini:'32px',
action:function(v){
this.boxing().refresh();
}
Expand Down
3 changes: 1 addition & 2 deletions xui/js/UI/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,7 @@ xui.Class("xui.UI.Input", ["xui.UI.Widget","xui.absValue"] ,{
}
},
autoexpand:{
$spaceunit:1,
ini:"",
ini:false,
action:function(v){
this.boxing().refresh();
}
Expand Down
35 changes: 18 additions & 17 deletions xui/js/xui.js
Original file line number Diff line number Diff line change
Expand Up @@ -4876,7 +4876,8 @@ xui.Class('xui.absProfile',null,{
upper=null;
if(!this.$xid)this.$xid=xui.absProfile.$xid.next();
this._$cache={};
this._ctrlpool={};
this._alias_pool={};
this._ref_pool={};

this._links={};
this.link(xui._pool,'xui');
Expand All @@ -4885,7 +4886,7 @@ xui.Class('xui.absProfile',null,{
__gc:function(){
this.unLinkAll();
this._links = null;
this._$cache=this._ctrlpool=null;
this._$cache=this._alias_pool=this._ref_pool=null;
},
getId:function(){
return this.$xid;
Expand Down Expand Up @@ -4974,6 +4975,9 @@ xui.Class('xui.absProfile',null,{
},
getChildrenId:function(){
return this.childrenId;
},
getByRef:function(ref){
return this._ref_pool[ref];
}
},
Static:{
Expand Down Expand Up @@ -5065,10 +5069,11 @@ xui.Class('xui.Profile','xui.absProfile',{
var o;
if(ns.alias && ns.host && (o=ns.host[ns.alias]) && (o=o._nodes) && (o.length===0 || o.length===1 && o[0]==ns)){
try{if(ns.alias in ns.host)delete ns.host[ns.alias];}catch(e){ns.host[ns.alias]=void(0)}
if(ns.host._ctrlpool && (ns.alias in ns.host._ctrlpool))delete ns.host._ctrlpool[ns.alias];
if(ns.host._alias_pool && (ns.alias in ns.host._alias_pool))delete ns.host._alias_pool[ns.alias];
}
if(ns.ref && ns.host && (o=ns.host[ns.ref]) && (o=o._nodes) && (o.length===0 || o.length===1 && o[0]==ns)){
try{if(ns.ref in ns.host)delete ns.host[ns.ref];}catch(e){ns.host[ns.ref]=void(0)}
if(ns.host._ref_pool && (ns.ref in ns.host._ref_pool))delete ns.host._ref_pool[ns.ref];
}

xui.absProfile.prototype.__gc.call(this);
Expand Down Expand Up @@ -5542,10 +5547,11 @@ xui.Class('xui.absObj',"xui.absBox",{
prf.host = null;
if(alias){
try{if(alias in host)delete host[alias];}catch(e){host[alias]=void(0)}
if(host._ctrlpool&&(alias in host._ctrlpool))delete host._ctrlpool[alias];
if(host._alias_pool&&(alias in host._alias_pool))delete host._alias_pool[alias];
}
if(ref){
try{if(ref in host)delete host[ref];}catch(e){host[ref]=void(0)}
if(host._ref_pool&&(ref in host._ref_pool))delete host._ref_pool[ref];
}
}
},
Expand All @@ -5565,9 +5571,6 @@ xui.Class('xui.absObj',"xui.absBox",{

// check new alias
if(alias){
if(/^\$.+#[\d]+$/.test(alias)){
throw new Error("The alias '"+alias+"' format error");
}
var t_host = host || oldHost;
if(t_host && (alias in t_host) && xui.isSet(t_host[alias]) && t_host[alias]!==self){
// can't rewrite existing memeber except xui.absObj
Expand All @@ -5581,9 +5584,6 @@ xui.Class('xui.absObj',"xui.absBox",{
}
}
if(ref){
if(!/^\$.+#[\d]+$/.test(ref)){
throw new Error("The ref '"+ref+"' format error");
}
var t_host = host || oldHost;
if(t_host && (ref in t_host) && t_host[ref]!==self){
// can't rewrite existing memeber except xui.absObj
Expand All @@ -5597,8 +5597,8 @@ xui.Class('xui.absObj',"xui.absBox",{
// clear old
if(oldHost && oldAlias){
try{if(oldAlias in oldHost)delete oldHost[oldAlias];}catch(e){oldHost[oldAlias]=void(0)}
if(xui.isHash(oldHost._ctrlpool)&&(oldAlias in oldHost._ctrlpool))
delete oldHost._ctrlpool[oldAlias];
if(xui.isHash(oldHost._alias_pool)&&(oldAlias in oldHost._alias_pool))
delete oldHost._alias_pool[oldAlias];
}

// reset host & name
Expand All @@ -5620,8 +5620,8 @@ xui.Class('xui.absObj',"xui.absBox",{
if(oldHost==host){
if(oldAlias && oldAlias!==alias){
try{if(oldAlias in host)delete host[oldAlias];}catch(e){host[oldAlias]=void(0)}
if(xui.isHash(host._ctrlpool) && (oldAlias in host._ctrlpool))
delete host._ctrlpool[oldAlias];
if(xui.isHash(host._alias_pool) && (oldAlias in host._alias_pool))
delete host._alias_pool[oldAlias];

if(prf.box && prf.box._syncAlias){
prf.box._syncAlias(prf, oldAlias, alias);
Expand All @@ -5630,11 +5630,12 @@ xui.Class('xui.absObj',"xui.absBox",{
}

host[alias]=self;
if(xui.isHash(host._ctrlpool))
host._ctrlpool[alias]=self.get(0);
if(xui.isHash(host._alias_pool))
host._alias_pool[alias]=self.get(0);

if(ref && oldRef!==ref){
host[ref]=self;
if(xui.isHash(host._ref_pool))
host._ref_pool[ref]=self.get(0);
}
}
return self;
Expand Down

0 comments on commit 1f1cf48

Please sign in to comment.