1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
dojo._xdResourceLoaded(function(dojo, dijit, dojox){
return {depends: [["provide", "dojox.dtl.Context"],
["require", "dojox.dtl._base"]],
defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.dtl.Context"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.Context"] = true;
dojo.provide("dojox.dtl.Context");
dojo.require("dojox.dtl._base");
dojox.dtl.Context = dojo.extend(function(dict){
this._this = {};
dojox.dtl._Context.call(this, dict);
}, dojox.dtl._Context.prototype,
{
getKeys: function(){
var keys = [];
for(var key in this){
if(this.hasOwnProperty(key) && key != "_this"){
keys.push(key);
}
}
return keys;
},
extend: function(/*dojox.dtl.Context|Object*/ obj){
// summary: Returns a clone of this context object, with the items from the
// passed objecct mixed in.
return dojo.delegate(this, obj);
},
filter: function(/*dojox.dtl.Context|Object|String...*/ filter){
// summary: Returns a clone of this context, only containing the items
// defined in the filter.
var context = new dojox.dtl.Context();
var keys = [];
var i, arg;
if(filter instanceof dojox.dtl.Context){
keys = filter.getKeys();
}else if(typeof filter == "object"){
for(var key in filter){
keys.push(key);
}
}else{
for(i = 0; arg = arguments[i]; i++){
if(typeof arg == "string"){
keys.push(arg);
}
}
}
for(i = 0, key; key = keys[i]; i++){
context[key] = this[key];
}
return context;
},
setThis: function(/*Object*/ _this){
this._this = _this;
},
getThis: function(){
return this._this;
},
hasKey: function(key){
if(this._getter){
var got = this._getter(key);
if(typeof got != "undefined"){
return true;
}
}
if(typeof this[key] != "undefined"){
return true;
}
return false;
}
});
}
}};});
|