]> git.wh0rd.org - tt-rss.git/blob - lib/dojo/_base/lang.js
add dijit/dojo stuff; initial ui mockup
[tt-rss.git] / lib / dojo / _base / lang.js
1 /*
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
5 */
6
7
8 if(!dojo._hasResource["dojo._base.lang"]){
9 dojo._hasResource["dojo._base.lang"]=true;
10 dojo.provide("dojo._base.lang");
11 (function(){
12 var d=dojo,_1=Object.prototype.toString;
13 dojo.isString=function(it){
14 return (typeof it=="string"||it instanceof String);
15 };
16 dojo.isArray=function(it){
17 return it&&(it instanceof Array||typeof it=="array");
18 };
19 dojo.isFunction=function(it){
20 return _1.call(it)==="[object Function]";
21 };
22 dojo.isObject=function(it){
23 return it!==undefined&&(it===null||typeof it=="object"||d.isArray(it)||d.isFunction(it));
24 };
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));
27 };
28 dojo.isAlien=function(it){
29 return it&&!d.isFunction(it)&&/\{\s*\[native code\]\s*\}/.test(String(it));
30 };
31 dojo.extend=function(_2,_3){
32 for(var i=1,l=arguments.length;i<l;i++){
33 d._mixin(_2.prototype,arguments[i]);
34 }
35 return _2;
36 };
37 dojo._hitchArgs=function(_4,_5){
38 var _6=d._toArray(arguments,2);
39 var _7=d.isString(_5);
40 return function(){
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));
44 };
45 };
46 dojo.hitch=function(_9,_a){
47 if(arguments.length>2){
48 return d._hitchArgs.apply(d,arguments);
49 }
50 if(!_a){
51 _a=_9;
52 _9=null;
53 }
54 if(d.isString(_a)){
55 _9=_9||d.global;
56 if(!_9[_a]){
57 throw (["dojo.hitch: scope[\"",_a,"\"] is null (scope=\"",_9,"\")"].join(""));
58 }
59 return function(){
60 return _9[_a].apply(_9,arguments||[]);
61 };
62 }
63 return !_9?_a:function(){
64 return _a.apply(_9,arguments||[]);
65 };
66 };
67 dojo.delegate=dojo._delegate=(function(){
68 function _b(){
69 };
70 return function(_c,_d){
71 _b.prototype=_c;
72 var _e=new _b();
73 _b.prototype=null;
74 if(_d){
75 d._mixin(_e,_d);
76 }
77 return _e;
78 };
79 })();
80 var _f=function(obj,_10,_11){
81 return (_11||[]).concat(Array.prototype.slice.call(obj,_10||0));
82 };
83 var _12=function(obj,_13,_14){
84 var arr=_14||[];
85 for(var x=_13||0;x<obj.length;x++){
86 arr.push(obj[x]);
87 }
88 return arr;
89 };
90 dojo._toArray=d.isIE?function(obj){
91 return ((obj.item)?_12:_f).apply(this,arguments);
92 }:_f;
93 dojo.partial=function(_15){
94 var arr=[null];
95 return d.hitch.apply(d,arr.concat(d._toArray(arguments)));
96 };
97 var _16=d._extraNames,_17=_16.length,_18={};
98 dojo.clone=function(o){
99 if(!o||typeof o!="object"||d.isFunction(o)){
100 return o;
101 }
102 if(o.nodeType&&"cloneNode" in o){
103 return o.cloneNode(true);
104 }
105 if(o instanceof Date){
106 return new Date(o.getTime());
107 }
108 var r,i,l,s,_19;
109 if(d.isArray(o)){
110 r=[];
111 for(i=0,l=o.length;i<l;++i){
112 if(i in o){
113 r.push(d.clone(o[i]));
114 }
115 }
116 }else{
117 r=o.constructor?new o.constructor():{};
118 }
119 for(_19 in o){
120 s=o[_19];
121 if(!(_19 in r)||(r[_19]!==s&&(!(_19 in _18)||_18[_19]!==s))){
122 r[_19]=d.clone(s);
123 }
124 }
125 if(_17){
126 for(i=0;i<_17;++i){
127 _19=_16[i];
128 s=o[_19];
129 if(!(_19 in r)||(r[_19]!==s&&(!(_19 in _18)||_18[_19]!==s))){
130 r[_19]=s;
131 }
132 }
133 }
134 return r;
135 };
136 dojo.trim=String.prototype.trim?function(str){
137 return str.trim();
138 }:function(str){
139 return str.replace(/^\s\s*/,"").replace(/\s\s*$/,"");
140 };
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);
145 });
146 };
147 })();
148 }