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