2150 |
mathias |
1 |
if(!dojo._hasResource["dojox.dtl.tag.event"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
|
|
2 |
dojo._hasResource["dojox.dtl.tag.event"] = true;
|
|
|
3 |
dojo.provide("dojox.dtl.tag.event");
|
|
|
4 |
|
|
|
5 |
dojo.require("dojox.dtl._base");
|
|
|
6 |
|
|
|
7 |
dojox.dtl.tag.event.EventNode = function(type, fn){
|
|
|
8 |
this._type = type;
|
|
|
9 |
this.contents = fn;
|
|
|
10 |
}
|
|
|
11 |
dojo.extend(dojox.dtl.tag.event.EventNode, {
|
|
|
12 |
render: function(context, buffer){
|
|
|
13 |
if(!this._clear){
|
|
|
14 |
buffer.getParent()[this._type] = null;
|
|
|
15 |
this._clear = true;
|
|
|
16 |
}
|
|
|
17 |
if(this.contents && !this._rendered){
|
|
|
18 |
if(!context.getThis()) throw new Error("You must use Context.setObject(instance)");
|
|
|
19 |
this._rendered = dojo.connect(buffer.getParent(), this._type, context.getThis(), this.contents);
|
|
|
20 |
}
|
|
|
21 |
return buffer;
|
|
|
22 |
},
|
|
|
23 |
unrender: function(context, buffer){
|
|
|
24 |
if(this._rendered){
|
|
|
25 |
dojo.disconnect(this._rendered);
|
|
|
26 |
this._rendered = false;
|
|
|
27 |
}
|
|
|
28 |
return buffer;
|
|
|
29 |
},
|
|
|
30 |
clone: function(){
|
|
|
31 |
return new dojox.dtl.tag.event.EventNode(this._type, this.contents);
|
|
|
32 |
},
|
|
|
33 |
toString: function(){ return "dojox.dtl.tag.event." + this._type; }
|
|
|
34 |
});
|
|
|
35 |
|
|
|
36 |
dojox.dtl.tag.event.on = function(parser, text){
|
|
|
37 |
// summary: Associates an event type to a function (on the current widget) by name
|
|
|
38 |
var parts = text.split(" ");
|
|
|
39 |
return new dojox.dtl.tag.event.EventNode(parts[0], parts[1]);
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
}
|