Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1318 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.lang.common");
13
dojo.provide("dojo.lang.common");
12
dojo.lang.inherits = function (subclass, superclass) {
14
dojo.lang.inherits = function (subclass, superclass) {
13
	if (!dojo.lang.isFunction(superclass)) {
15
	if (!dojo.lang.isFunction(superclass)) {
14
		dojo.raise("dojo.inherits: superclass argument [" + superclass + "] must be a function (subclass: [" + subclass + "']");
16
		dojo.raise("dojo.inherits: superclass argument [" + superclass + "] must be a function (subclass: [" + subclass + "']");
15
	}
17
	}
16
	subclass.prototype = new superclass();
18
	subclass.prototype = new superclass();
17
	subclass.prototype.constructor = subclass;
19
	subclass.prototype.constructor = subclass;
18
	subclass.superclass = superclass.prototype;
20
	subclass.superclass = superclass.prototype;
19
	subclass["super"] = superclass.prototype;
21
	subclass["super"] = superclass.prototype;
20
};
22
};
21
dojo.lang._mixin = function (obj, props) {
23
dojo.lang._mixin = function (obj, props) {
22
	var tobj = {};
24
	var tobj = {};
23
	for (var x in props) {
25
	for (var x in props) {
24
		if ((typeof tobj[x] == "undefined") || (tobj[x] != props[x])) {
26
		if ((typeof tobj[x] == "undefined") || (tobj[x] != props[x])) {
25
			obj[x] = props[x];
27
			obj[x] = props[x];
26
		}
28
		}
27
	}
29
	}
28
	if (dojo.render.html.ie && (typeof (props["toString"]) == "function") && (props["toString"] != obj["toString"]) && (props["toString"] != tobj["toString"])) {
30
	if (dojo.render.html.ie && (typeof (props["toString"]) == "function") && (props["toString"] != obj["toString"]) && (props["toString"] != tobj["toString"])) {
29
		obj.toString = props.toString;
31
		obj.toString = props.toString;
30
	}
32
	}
31
	return obj;
33
	return obj;
32
};
34
};
33
dojo.lang.mixin = function (obj, props) {
35
dojo.lang.mixin = function (obj, props) {
34
	for (var i = 1, l = arguments.length; i < l; i++) {
36
	for (var i = 1, l = arguments.length; i < l; i++) {
35
		dojo.lang._mixin(obj, arguments[i]);
37
		dojo.lang._mixin(obj, arguments[i]);
36
	}
38
	}
37
	return obj;
39
	return obj;
38
};
40
};
39
dojo.lang.extend = function (constructor, props) {
41
dojo.lang.extend = function (constructor, props) {
40
	for (var i = 1, l = arguments.length; i < l; i++) {
42
	for (var i = 1, l = arguments.length; i < l; i++) {
41
		dojo.lang._mixin(constructor.prototype, arguments[i]);
43
		dojo.lang._mixin(constructor.prototype, arguments[i]);
42
	}
44
	}
43
	return constructor;
45
	return constructor;
44
};
46
};
45
dojo.inherits = dojo.lang.inherits;
47
dojo.inherits = dojo.lang.inherits;
46
dojo.mixin = dojo.lang.mixin;
48
dojo.mixin = dojo.lang.mixin;
47
dojo.extend = dojo.lang.extend;
49
dojo.extend = dojo.lang.extend;
48
dojo.lang.find = function (array, value, identity, findLast) {
50
dojo.lang.find = function (array, value, identity, findLast) {
49
	if (!dojo.lang.isArrayLike(array) && dojo.lang.isArrayLike(value)) {
51
	if (!dojo.lang.isArrayLike(array) && dojo.lang.isArrayLike(value)) {
50
		dojo.deprecated("dojo.lang.find(value, array)", "use dojo.lang.find(array, value) instead", "0.5");
52
		dojo.deprecated("dojo.lang.find(value, array)", "use dojo.lang.find(array, value) instead", "0.5");
51
		var temp = array;
53
		var temp = array;
52
		array = value;
54
		array = value;
53
		value = temp;
55
		value = temp;
54
	}
56
	}
55
	var isString = dojo.lang.isString(array);
57
	var isString = dojo.lang.isString(array);
56
	if (isString) {
58
	if (isString) {
57
		array = array.split("");
59
		array = array.split("");
58
	}
60
	}
59
	if (findLast) {
61
	if (findLast) {
60
		var step = -1;
62
		var step = -1;
61
		var i = array.length - 1;
63
		var i = array.length - 1;
62
		var end = -1;
64
		var end = -1;
63
	} else {
65
	} else {
64
		var step = 1;
66
		var step = 1;
65
		var i = 0;
67
		var i = 0;
66
		var end = array.length;
68
		var end = array.length;
67
	}
69
	}
68
	if (identity) {
70
	if (identity) {
69
		while (i != end) {
71
		while (i != end) {
70
			if (array[i] === value) {
72
			if (array[i] === value) {
71
				return i;
73
				return i;
72
			}
74
			}
73
			i += step;
75
			i += step;
74
		}
76
		}
75
	} else {
77
	} else {
76
		while (i != end) {
78
		while (i != end) {
77
			if (array[i] == value) {
79
			if (array[i] == value) {
78
				return i;
80
				return i;
79
			}
81
			}
80
			i += step;
82
			i += step;
81
		}
83
		}
82
	}
84
	}
83
	return -1;
85
	return -1;
84
};
86
};
85
dojo.lang.indexOf = dojo.lang.find;
87
dojo.lang.indexOf = dojo.lang.find;
86
dojo.lang.findLast = function (array, value, identity) {
88
dojo.lang.findLast = function (array, value, identity) {
87
	return dojo.lang.find(array, value, identity, true);
89
	return dojo.lang.find(array, value, identity, true);
88
};
90
};
89
dojo.lang.lastIndexOf = dojo.lang.findLast;
91
dojo.lang.lastIndexOf = dojo.lang.findLast;
90
dojo.lang.inArray = function (array, value) {
92
dojo.lang.inArray = function (array, value) {
91
	return dojo.lang.find(array, value) > -1;
93
	return dojo.lang.find(array, value) > -1;
92
};
94
};
93
dojo.lang.isObject = function (it) {
95
dojo.lang.isObject = function (it) {
94
	if (typeof it == "undefined") {
96
	if (typeof it == "undefined") {
95
		return false;
97
		return false;
96
	}
98
	}
97
	return (typeof it == "object" || it === null || dojo.lang.isArray(it) || dojo.lang.isFunction(it));
99
	return (typeof it == "object" || it === null || dojo.lang.isArray(it) || dojo.lang.isFunction(it));
98
};
100
};
99
dojo.lang.isArray = function (it) {
101
dojo.lang.isArray = function (it) {
100
	return (it && it instanceof Array || typeof it == "array");
102
	return (it && it instanceof Array || typeof it == "array");
101
};
103
};
102
dojo.lang.isArrayLike = function (it) {
104
dojo.lang.isArrayLike = function (it) {
103
	if ((!it) || (dojo.lang.isUndefined(it))) {
105
	if ((!it) || (dojo.lang.isUndefined(it))) {
104
		return false;
106
		return false;
105
	}
107
	}
106
	if (dojo.lang.isString(it)) {
108
	if (dojo.lang.isString(it)) {
107
		return false;
109
		return false;
108
	}
110
	}
109
	if (dojo.lang.isFunction(it)) {
111
	if (dojo.lang.isFunction(it)) {
110
		return false;
112
		return false;
111
	}
113
	}
112
	if (dojo.lang.isArray(it)) {
114
	if (dojo.lang.isArray(it)) {
113
		return true;
115
		return true;
114
	}
116
	}
115
	if ((it.tagName) && (it.tagName.toLowerCase() == "form")) {
117
	if ((it.tagName) && (it.tagName.toLowerCase() == "form")) {
116
		return false;
118
		return false;
117
	}
119
	}
118
	if (dojo.lang.isNumber(it.length) && isFinite(it.length)) {
120
	if (dojo.lang.isNumber(it.length) && isFinite(it.length)) {
119
		return true;
121
		return true;
120
	}
122
	}
121
	return false;
123
	return false;
122
};
124
};
123
dojo.lang.isFunction = function (it) {
125
dojo.lang.isFunction = function (it) {
124
	return (it instanceof Function || typeof it == "function");
126
	return (it instanceof Function || typeof it == "function");
125
};
127
};
126
(function () {
128
(function () {
127
	if ((dojo.render.html.capable) && (dojo.render.html["safari"])) {
129
	if ((dojo.render.html.capable) && (dojo.render.html["safari"])) {
128
		dojo.lang.isFunction = function (it) {
130
		dojo.lang.isFunction = function (it) {
129
			if ((typeof (it) == "function") && (it == "[object NodeList]")) {
131
			if ((typeof (it) == "function") && (it == "[object NodeList]")) {
130
				return false;
132
				return false;
131
			}
133
			}
132
			return (it instanceof Function || typeof it == "function");
134
			return (it instanceof Function || typeof it == "function");
133
		};
135
		};
134
	}
136
	}
135
})();
137
})();
136
dojo.lang.isString = function (it) {
138
dojo.lang.isString = function (it) {
137
	return (typeof it == "string" || it instanceof String);
139
	return (typeof it == "string" || it instanceof String);
138
};
140
};
139
dojo.lang.isAlien = function (it) {
141
dojo.lang.isAlien = function (it) {
140
	if (!it) {
142
	if (!it) {
141
		return false;
143
		return false;
142
	}
144
	}
143
	return !dojo.lang.isFunction(it) && /\{\s*\[native code\]\s*\}/.test(String(it));
145
	return !dojo.lang.isFunction(it) && /\{\s*\[native code\]\s*\}/.test(String(it));
144
};
146
};
145
dojo.lang.isBoolean = function (it) {
147
dojo.lang.isBoolean = function (it) {
146
	return (it instanceof Boolean || typeof it == "boolean");
148
	return (it instanceof Boolean || typeof it == "boolean");
147
};
149
};
148
dojo.lang.isNumber = function (it) {
150
dojo.lang.isNumber = function (it) {
149
	return (it instanceof Number || typeof it == "number");
151
	return (it instanceof Number || typeof it == "number");
150
};
152
};
151
dojo.lang.isUndefined = function (it) {
153
dojo.lang.isUndefined = function (it) {
152
	return ((typeof (it) == "undefined") && (it == undefined));
154
	return ((typeof (it) == "undefined") && (it == undefined));
153
};
155
};
154
 
156