Subversion Repositories Applications.papyrus

Rev

Rev 1987 | Details | Compare with Previous | 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.AdapterRegistry");
14
dojo.require("dojo.lang.func");
15
dojo.AdapterRegistry = function (returnWrappers) {
16
	this.pairs = [];
17
	this.returnWrappers = returnWrappers || false;
18
};
19
dojo.lang.extend(dojo.AdapterRegistry, {register:function (name, check, wrap, directReturn, override) {
20
	var type = (override) ? "unshift" : "push";
21
	this.pairs[type]([name, check, wrap, directReturn]);
22
}, match:function () {
23
	for (var i = 0; i < this.pairs.length; i++) {
24
		var pair = this.pairs[i];
25
		if (pair[1].apply(this, arguments)) {
26
			if ((pair[3]) || (this.returnWrappers)) {
27
				return pair[2];
28
			} else {
29
				return pair[2].apply(this, arguments);
30
			}
31
		}
32
	}
33
	throw new Error("No match found");
34
}, unregister:function (name) {
35
	for (var i = 0; i < this.pairs.length; i++) {
36
		var pair = this.pairs[i];
37
		if (pair[0] == name) {
38
			this.pairs.splice(i, 1);
39
			return true;
40
		}
41
	}
42
	return false;
43
}});
44