Subversion Repositories Applications.papyrus

Rev

Rev 1372 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1372 Rev 1422
1
/*
1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
3
	All Rights Reserved.
4
 
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
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:
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
9
*/
-
 
10
 
-
 
11
 
10
 
12
 
11
dojo.provide("dojo.AdapterRegistry");
13
dojo.provide("dojo.AdapterRegistry");
12
dojo.require("dojo.lang.func");
14
dojo.require("dojo.lang.func");
13
dojo.AdapterRegistry = function (returnWrappers) {
15
dojo.AdapterRegistry = function (returnWrappers) {
14
	this.pairs = [];
16
	this.pairs = [];
15
	this.returnWrappers = returnWrappers || false;
17
	this.returnWrappers = returnWrappers || false;
16
};
18
};
17
dojo.lang.extend(dojo.AdapterRegistry, {register:function (name, check, wrap, directReturn, override) {
19
dojo.lang.extend(dojo.AdapterRegistry, {register:function (name, check, wrap, directReturn, override) {
18
	var type = (override) ? "unshift" : "push";
20
	var type = (override) ? "unshift" : "push";
19
	this.pairs[type]([name, check, wrap, directReturn]);
21
	this.pairs[type]([name, check, wrap, directReturn]);
20
}, match:function () {
22
}, match:function () {
21
	for (var i = 0; i < this.pairs.length; i++) {
23
	for (var i = 0; i < this.pairs.length; i++) {
22
		var pair = this.pairs[i];
24
		var pair = this.pairs[i];
23
		if (pair[1].apply(this, arguments)) {
25
		if (pair[1].apply(this, arguments)) {
24
			if ((pair[3]) || (this.returnWrappers)) {
26
			if ((pair[3]) || (this.returnWrappers)) {
25
				return pair[2];
27
				return pair[2];
26
			} else {
28
			} else {
27
				return pair[2].apply(this, arguments);
29
				return pair[2].apply(this, arguments);
28
			}
30
			}
29
		}
31
		}
30
	}
32
	}
31
	throw new Error("No match found");
33
	throw new Error("No match found");
32
}, unregister:function (name) {
34
}, unregister:function (name) {
33
	for (var i = 0; i < this.pairs.length; i++) {
35
	for (var i = 0; i < this.pairs.length; i++) {
34
		var pair = this.pairs[i];
36
		var pair = this.pairs[i];
35
		if (pair[0] == name) {
37
		if (pair[0] == name) {
36
			this.pairs.splice(i, 1);
38
			this.pairs.splice(i, 1);
37
			return true;
39
			return true;
38
		}
40
		}
39
	}
41
	}
40
	return false;
42
	return false;
41
}});
43
}});
42
 
44