-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmain.js
68 lines (58 loc) · 1.73 KB
/
main.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*jshint evil:true*/
if (typeof document !== "undefined") {
(function() {
minispade = {
root: null,
modules: {},
loaded: {},
globalEval: function(data) {
if ( data ) {
// We use execScript on Internet Explorer
// We use an anonymous function so that context is window
// rather than jQuery in Firefox
( window.execScript || function( data ) {
window[ "eval" ].call( window, data );
} )( data );
}
},
requireModule: function(name) {
var loaded = minispade.loaded[name];
var mod = minispade.modules[name];
if (!loaded) {
if (mod) {
minispade.loaded[name] = true;
if (typeof mod === "string") {
this.globalEval(mod);
} else {
mod();
}
} else {
if (minispade.root && name.substr(0,minispade.root.length) !== minispade.root) {
return minispade.requireModule(minispade.root+name);
} else {
throw "The module '" + name + "' could not be found";
}
}
}
return loaded;
},
requireAll: function(regex) {
for (var module in this.modules) {
if (!this.modules.hasOwnProperty(module)) { continue; }
if (regex && !regex.test(module)) { continue; }
minispade.requireModule(module);
}
},
require: function(path) {
if (typeof path === 'string') {
minispade.requireModule(path);
} else {
minispade.requireAll(path);
}
},
register: function(name, callback) {
minispade.modules[name] = callback;
}
};
})();
}