]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/_base/lang.js
2 Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3 Available via Academic Free License >= 2.1 OR the modified BSD license.
4 see: http://dojotoolkit.org/license for details
8 if(!dojo
._hasResource
["dojo._base.lang"]){
9 dojo
._hasResource
["dojo._base.lang"]=true;
10 dojo
.provide("dojo._base.lang");
12 var d
=dojo
,_1
=Object
.prototype.toString
;
13 dojo
.isString=function(it
){
14 return (typeof it
=="string"||it
instanceof String
);
16 dojo
.isArray=function(it
){
17 return it
&&(it
instanceof Array
||typeof it
=="array");
19 dojo
.isFunction=function(it
){
20 return _1
.call(it
)==="[object Function]";
22 dojo
.isObject=function(it
){
23 return it
!==undefined&&(it
===null||typeof it
=="object"||d
.isArray(it
)||d
.isFunction(it
));
25 dojo
.isArrayLike=function(it
){
26 return it
&&it
!==undefined&&!d
.isString(it
)&&!d
.isFunction(it
)&&!(it
.tagName
&&it
.tagName
.toLowerCase()=="form")&&(d
.isArray(it
)||isFinite(it
.length
));
28 dojo
.isAlien=function(it
){
29 return it
&&!d
.isFunction(it
)&&/\{\s*\[native code\]\s*\}/.test(String(it
));
31 dojo
.extend=function(_2
,_3
){
32 for(var i
=1,l
=arguments
.length
;i
<l
;i
++){
33 d
._mixin(_2
.prototype,arguments
[i
]);
37 dojo
._hitchArgs=function(_4
,_5
){
38 var _6
=d
._toArray(arguments
,2);
39 var _7
=d
.isString(_5
);
41 var _8
=d
._toArray(arguments
);
42 var f
=_7
?(_4
||d
.global
)[_5
]:_5
;
43 return f
&&f
.apply(_4
||this,_6
.concat(_8
));
46 dojo
.hitch=function(_9
,_a
){
47 if(arguments
.length
>2){
48 return d
._hitchArgs
.apply(d
,arguments
);
57 throw (["dojo.hitch: scope[\"",_a
,"\"] is null (scope=\"",_9
,"\")"].join(""));
60 return _9
[_a
].apply(_9
,arguments
||[]);
63 return !_9
?_a:function(){
64 return _a
.apply(_9
,arguments
||[]);
67 dojo
.delegate
=dojo
._delegate
=(function(){
70 return function(_c
,_d
){
80 var _f=function(obj
,_10
,_11
){
81 return (_11
||[]).concat(Array
.prototype.slice
.call(obj
,_10
||0));
83 var _12=function(obj
,_13
,_14
){
85 for(var x
=_13
||0;x
<obj
.length
;x
++){
90 dojo
._toArray
=d
.isIE
?function(obj
){
91 return ((obj
.item
)?_12
:_f
).apply(this,arguments
);
93 dojo
.partial=function(_15
){
95 return d
.hitch
.apply(d
,arr
.concat(d
._toArray(arguments
)));
97 var _16
=d
._extraNames
,_17
=_16
.length
,_18
={};
98 dojo
.clone=function(o
){
99 if(!o
||typeof o
!="object"||d
.isFunction(o
)){
102 if(o
.nodeType
&&"cloneNode" in o
){
103 return o
.cloneNode(true);
105 if(o
instanceof Date
){
106 return new Date(o
.getTime());
111 for(i
=0,l
=o
.length
;i
<l
;++i
){
113 r
.push(d
.clone(o
[i
]));
117 r
=o
.constructor?new o
.constructor():{};
121 if(!(_19
in r
)||(r
[_19
]!==s
&&(!(_19
in _18
)||_18
[_19
]!==s
))){
129 if(!(_19
in r
)||(r
[_19
]!==s
&&(!(_19
in _18
)||_18
[_19
]!==s
))){
136 dojo
.trim
=String
.prototype.trim
?function(str
){
139 return str
.replace(/^\s\s*/,"").replace(/\s\s*$/,"");
141 var _1a
=/\{([^\}]+)\}/g;
142 dojo
.replace=function(_1b
,map
,_1c
){
143 return _1b
.replace(_1c
||_1a
,d
.isFunction(map
)?map:function(_1d
,k
){
144 return d
.getObject(k
,false,map
);