Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.ns");
14
dojo.ns = {namespaces:{}, failed:{}, loading:{}, loaded:{}, register:function (name, module, resolver, noOverride) {
15
	if (!noOverride || !this.namespaces[name]) {
16
		this.namespaces[name] = new dojo.ns.Ns(name, module, resolver);
17
	}
18
}, allow:function (name) {
19
	if (this.failed[name]) {
20
		return false;
21
	}
22
	if ((djConfig.excludeNamespace) && (dojo.lang.inArray(djConfig.excludeNamespace, name))) {
23
		return false;
24
	}
25
	return ((name == this.dojo) || (!djConfig.includeNamespace) || (dojo.lang.inArray(djConfig.includeNamespace, name)));
26
}, get:function (name) {
27
	return this.namespaces[name];
28
}, require:function (name) {
29
	var ns = this.namespaces[name];
30
	if ((ns) && (this.loaded[name])) {
31
		return ns;
32
	}
33
	if (!this.allow(name)) {
34
		return false;
35
	}
36
	if (this.loading[name]) {
37
		dojo.debug("dojo.namespace.require: re-entrant request to load namespace \"" + name + "\" must fail.");
38
		return false;
39
	}
40
	var req = dojo.require;
41
	this.loading[name] = true;
42
	try {
43
		if (name == "dojo") {
44
			req("dojo.namespaces.dojo");
45
		} else {
46
			if (!dojo.hostenv.moduleHasPrefix(name)) {
47
				dojo.registerModulePath(name, "../" + name);
48
			}
49
			req([name, "manifest"].join("."), false, true);
50
		}
51
		if (!this.namespaces[name]) {
52
			this.failed[name] = true;
53
		}
54
	}
55
	finally {
56
		this.loading[name] = false;
57
	}
58
	return this.namespaces[name];
59
}};
60
dojo.ns.Ns = function (name, module, resolver) {
61
	this.name = name;
62
	this.module = module;
63
	this.resolver = resolver;
64
	this._loaded = [];
65
	this._failed = [];
66
};
67
dojo.ns.Ns.prototype.resolve = function (name, domain, omitModuleCheck) {
68
	if (!this.resolver || djConfig["skipAutoRequire"]) {
69
		return false;
70
	}
71
	var fullName = this.resolver(name, domain);
72
	if ((fullName) && (!this._loaded[fullName]) && (!this._failed[fullName])) {
73
		var req = dojo.require;
74
		req(fullName, false, true);
75
		if (dojo.hostenv.findModule(fullName, false)) {
76
			this._loaded[fullName] = true;
77
		} else {
78
			if (!omitModuleCheck) {
79
				dojo.raise("dojo.ns.Ns.resolve: module '" + fullName + "' not found after loading via namespace '" + this.name + "'");
80
			}
81
			this._failed[fullName] = true;
82
		}
83
	}
84
	return Boolean(this._loaded[fullName]);
85
};
86
dojo.registerNamespace = function (name, module, resolver) {
87
	dojo.ns.register.apply(dojo.ns, arguments);
88
};
89
dojo.registerNamespaceResolver = function (name, resolver) {
90
	var n = dojo.ns.namespaces[name];
91
	if (n) {
92
		n.resolver = resolver;
93
	}
94
};
95
dojo.registerNamespaceManifest = function (module, path, name, widgetModule, resolver) {
96
	dojo.registerModulePath(name, path);
97
	dojo.registerNamespace(name, widgetModule, resolver);
98
};
99
dojo.registerNamespace("dojo", "dojo.widget");
100