Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / dtl / contrib / dijit.js

History | View | Annotate | Download (4.41 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.contrib.dijit"]){
9
dojo._hasResource["dojox.dtl.contrib.dijit"]=true;
10
dojo.provide("dojox.dtl.contrib.dijit");
11
dojo.require("dojox.dtl.dom");
12
dojo.require("dojo.parser");
13
(function(){
14
var dd=dojox.dtl;
15
var _1=dd.contrib.dijit;
16
_1.AttachNode=dojo.extend(function(_2,_3){
17
this._keys=_2;
18
this._object=_3;
19
},{render:function(_4,_5){
20
if(!this._rendered){
21
this._rendered=true;
22
for(var i=0,_6;_6=this._keys[i];i++){
23
_4.getThis()[_6]=this._object||_5.getParent();
24
}
25
}
26
return _5;
27
},unrender:function(_7,_8){
28
if(this._rendered){
29
this._rendered=false;
30
for(var i=0,_9;_9=this._keys[i];i++){
31
if(_7.getThis()[_9]===(this._object||_8.getParent())){
32
delete _7.getThis()[_9];
33
}
34
}
35
}
36
return _8;
37
},clone:function(_a){
38
return new this.constructor(this._keys,this._object);
39
}});
40
_1.EventNode=dojo.extend(function(_b,_c){
41
this._command=_b;
42
var _d,_e=_b.split(/\s*,\s*/);
43
var _f=dojo.trim;
44
var _10=[];
45
var fns=[];
46
while(_d=_e.pop()){
47
if(_d){
48
var fn=null;
49
if(_d.indexOf(":")!=-1){
50
var _11=_d.split(":");
51
_d=_f(_11[0]);
52
fn=_f(_11.slice(1).join(":"));
53
}else{
54
_d=_f(_d);
55
}
56
if(!fn){
57
fn=_d;
58
}
59
_10.push(_d);
60
fns.push(fn);
61
}
62
}
63
this._types=_10;
64
this._fns=fns;
65
this._object=_c;
66
this._rendered=[];
67
},{_clear:false,render:function(_12,_13){
68
for(var i=0,_14;_14=this._types[i];i++){
69
if(!this._clear&&!this._object){
70
_13.getParent()[_14]=null;
71
}
72
var fn=this._fns[i];
73
var _15;
74
if(fn.indexOf(" ")!=-1){
75
if(this._rendered[i]){
76
dojo.disconnect(this._rendered[i]);
77
this._rendered[i]=false;
78
}
79
_15=dojo.map(fn.split(" ").slice(1),function(_16){
80
return new dd._Filter(_16).resolve(_12);
81
});
82
fn=fn.split(" ",2)[0];
83
}
84
if(!this._rendered[i]){
85
if(!this._object){
86
this._rendered[i]=_13.addEvent(_12,_14,fn,_15);
87
}else{
88
this._rendered[i]=dojo.connect(this._object,_14,_12.getThis(),fn);
89
}
90
}
91
}
92
this._clear=true;
93
return _13;
94
},unrender:function(_17,_18){
95
while(this._rendered.length){
96
dojo.disconnect(this._rendered.pop());
97
}
98
return _18;
99
},clone:function(){
100
return new this.constructor(this._command,this._object);
101
}});
102
function _19(n1){
103
var n2=n1.cloneNode(true);
104
if(dojo.isIE){
105
dojo.query("script",n2).forEach("item.text = this[index].text;",dojo.query("script",n1));
106
}
107
return n2;
108
};
109
_1.DojoTypeNode=dojo.extend(function(_1a,_1b){
110
this._node=_1a;
111
this._parsed=_1b;
112
var _1c=_1a.getAttribute("dojoAttachEvent");
113
if(_1c){
114
this._events=new _1.EventNode(dojo.trim(_1c));
115
}
116
var _1d=_1a.getAttribute("dojoAttachPoint");
117
if(_1d){
118
this._attach=new _1.AttachNode(dojo.trim(_1d).split(/\s*,\s*/));
119
}
120
if(!_1b){
121
this._dijit=dojo.parser.instantiate([_19(_1a)])[0];
122
}else{
123
_1a=_19(_1a);
124
var old=_1.widgetsInTemplate;
125
_1.widgetsInTemplate=false;
126
this._template=new dd.DomTemplate(_1a);
127
_1.widgetsInTemplate=old;
128
}
129
},{render:function(_1e,_1f){
130
if(this._parsed){
131
var _20=new dd.DomBuffer();
132
this._template.render(_1e,_20);
133
var _21=_19(_20.getRootNode());
134
var div=document.createElement("div");
135
div.appendChild(_21);
136
var _22=div.innerHTML;
137
div.removeChild(_21);
138
if(_22!=this._rendered){
139
this._rendered=_22;
140
if(this._dijit){
141
this._dijit.destroyRecursive();
142
}
143
this._dijit=dojo.parser.instantiate([_21])[0];
144
}
145
}
146
var _23=this._dijit.domNode;
147
if(this._events){
148
this._events._object=this._dijit;
149
this._events.render(_1e,_1f);
150
}
151
if(this._attach){
152
this._attach._object=this._dijit;
153
this._attach.render(_1e,_1f);
154
}
155
return _1f.concat(_23);
156
},unrender:function(_24,_25){
157
return _25.remove(this._dijit.domNode);
158
},clone:function(){
159
return new this.constructor(this._node,this._parsed);
160
}});
161
dojo.mixin(_1,{widgetsInTemplate:true,dojoAttachPoint:function(_26,_27){
162
return new _1.AttachNode(_27.contents.slice(16).split(/\s*,\s*/));
163
},dojoAttachEvent:function(_28,_29){
164
return new _1.EventNode(_29.contents.slice(16));
165
},dojoType:function(_2a,_2b){
166
var _2c=false;
167
if(_2b.contents.slice(-7)==" parsed"){
168
_2c=true;
169
}
170
var _2d=_2b.contents.slice(9);
171
var _2e=_2c?_2d.slice(0,-7):_2d.toString();
172
if(_1.widgetsInTemplate){
173
var _2f=_2a.swallowNode();
174
_2f.setAttribute("dojoType",_2e);
175
return new _1.DojoTypeNode(_2f,_2c);
176
}
177
return new dd.AttributeNode("dojoType",_2e);
178
},on:function(_30,_31){
179
var _32=_31.contents.split();
180
return new _1.EventNode(_32[0]+":"+_32.slice(1).join(" "));
181
}});
182
dd.register.tags("dojox.dtl.contrib",{"dijit":["attr:dojoType","attr:dojoAttachPoint",["attr:attach","dojoAttachPoint"],"attr:dojoAttachEvent",[/(attr:)?on(click|key(up))/i,"on"]]});
183
})();
184
}