cirandas.net

ref: master

public/javascripts/tinymce/tests/js/module_loader.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
(function(exports) {
	exports.AMDLC_TESTS = true;

	function resolve(id) {
		var i, target = exports, fragments = id.split(/[.\/]/);

		for (i = 0; i < fragments.length; i++) {
			if (!target[fragments[i]]) {
				return;
			}

			target = target[fragments[i]];
		}

		return target;
	}

	function require(ids, callback) {
		var i, module, defs = [], privateModules = exports.privateModules || {};

		for (i = 0; i < ids.length; i++) {
			module = privateModules[ids[i]] || resolve(ids[i]);

			if (!module) {
				throw 'module definition dependecy not found: ' + ids[i];
			}

			defs.push(module);
		}

		callback.apply(null, defs);
	}

	exports.ModuleLoader = {
		require: require
	};
})(this);