Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / dtl / _Templated.js @ 12

History | View | Annotate | Download (2.22 KB)

1 9 andrej.cim
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6
7
8
if(!dojo._hasResource["dojox.dtl._Templated"]){
9
dojo._hasResource["dojox.dtl._Templated"]=true;
10
dojo.provide("dojox.dtl._Templated");
11
dojo.require("dijit._Templated");
12
dojo.require("dojox.dtl._base");
13
dojo.declare("dojox.dtl._Templated",dijit._Templated,{_dijitTemplateCompat:false,buildRendering:function(){
14
var _1;
15
if(this.domNode&&!this._template){
16
return;
17
}
18
if(!this._template){
19
var t=this.getCachedTemplate(this.templatePath,this.templateString,this._skipNodeCache);
20
if(t instanceof dojox.dtl.Template){
21
this._template=t;
22
}else{
23
_1=t;
24
}
25
}
26
if(!_1){
27
var _2=new dojox.dtl._Context(this);
28
if(!this._created){
29
delete _2._getter;
30
}
31
var _3=dojo._toDom(this._template.render(_2));
32
if(_3.nodeType!==1&&_3.nodeType!==3){
33
for(var i=0,l=_3.childNodes.length;i<l;++i){
34
_1=_3.childNodes[i];
35
if(_1.nodeType==1){
36
break;
37
}
38
}
39
}else{
40
_1=_3;
41
}
42
}
43
this._attachTemplateNodes(_1);
44
if(this.widgetsInTemplate){
45
var _4=dojo.parser,_5,_6;
46
if(_4._query!="[dojoType]"){
47
_5=_4._query;
48
_6=_4._attrName;
49
_4._query="[dojoType]";
50
_4._attrName="dojoType";
51
}
52
var cw=(this._startupWidgets=dojo.parser.parse(_1,{noStart:!this._earlyTemplatedStartup,inherited:{dir:this.dir,lang:this.lang}}));
53
if(_5){
54
_4._query=_5;
55
_4._attrName=_6;
56
}
57
this._supportingWidgets=dijit.findWidgets(_1);
58
this._attachTemplateNodes(cw,function(n,p){
59
return n[p];
60
});
61
}
62
if(this.domNode){
63
dojo.place(_1,this.domNode,"before");
64
this.destroyDescendants();
65
dojo.destroy(this.domNode);
66
}
67
this.domNode=_1;
68
this._fillContent(this.srcNodeRef);
69
},_templateCache:{},getCachedTemplate:function(_7,_8,_9){
70
var _a=this._templateCache;
71
var _b=_8||_7;
72
if(_a[_b]){
73
return _a[_b];
74
}
75
_8=dojo.string.trim(_8||dojo.cache(_7,{sanitize:true}));
76
if(this._dijitTemplateCompat&&(_9||_8.match(/\$\{([^\}]+)\}/g))){
77
_8=this._stringRepl(_8);
78
}
79
if(_9||!_8.match(/\{[{%]([^\}]+)[%}]\}/g)){
80
return _a[_b]=dojo._toDom(_8);
81
}else{
82
return _a[_b]=new dojox.dtl.Template(_8);
83
}
84
},render:function(){
85
this.buildRendering();
86
},startup:function(){
87
dojo.forEach(this._startupWidgets,function(w){
88
if(w&&!w._started&&w.startup){
89
w.startup();
90
}
91
});
92
this.inherited(arguments);
93
}});
94
}