-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmagic.js
50 lines (44 loc) · 1.38 KB
/
magic.js
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
define(["dojo", "./base"], function(dojo, plugd){
var d = dojo;
d.dfdLoad = function(){
// summary: A version of `dojo.load` that returns a `dojo.Deferred` for those familar
// with that syntax. It is important to OMIT the callback function in the parameters
//
// example:
// | var req = dojo.dfdLoad("dijit.Dialog", "dijit.form.Button");
// | req.addCallback(function(){ ... })
//
// example:
// Allows .addErrBack() too
// | dojo.dfdLoad("dijit.NotThere").addErrBack(function(){ ... })
//
var dfd = new d.Deferred(), a = d._toArray(arguments);
a.push(dojo.hitch(dfd, 'callback'));
try{
d.load.apply(d, a);
}catch(e){
dfd.errback(e);
}
return dfd;
}
//>>excludeStart("superMagic", kwArgs.superMagic == "off")
d._addMagic = function(){ return;
// summary: Mix every public function in the `dojo` namespace into the
// global $ variable either a) when djConfig.conflict is true or
// to be called manually after any custom modules are added to
// the `dojo` namespace.
//
// example:
// | dojo.load("some.module", dojo._addMagic); // which adds dojo.fakeFunction
//
for(var i in d){
// if a) it isn't there, 2) isn't private, and c) is a function:
if(!$[i] && !(/^_/.test(i)) && d.isFunction(d[i])){
$[i] = d[i]; // map it
}
}
}
d.config.conflict && d._addMagic();
//>>excludeEnd("superMagic");
return d;
});