Project

General

Profile

Download (1.12 KB) Statistics
| Branch: | Revision:
1
/*
2
	Copyright (c) 2004-2008, 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.string"]){
9
dojo._hasResource["dojo.string"]=true;
10
dojo.provide("dojo.string");
11
dojo.string.rep=function(_1,_2){
12
if(_2<=0||!_1){
13
return "";
14
}
15
var _3=[];
16
for(;;){
17
if(_2&1){
18
_3.push(_1);
19
}
20
if(!(_2>>=1)){
21
break;
22
}
23
_1+=_1;
24
}
25
return _3.join("");
26
};
27
dojo.string.pad=function(_4,_5,ch,_7){
28
if(!ch){
29
ch="0";
30
}
31
var _8=String(_4),_9=dojo.string.rep(ch,Math.ceil((_5-_8.length)/ch.length));
32
return _7?_8+_9:_9+_8;
33
};
34
dojo.string.substitute=function(_a,_b,_c,_d){
35
_d=_d||dojo.global;
36
_c=(!_c)?function(v){
37
return v;
38
}:dojo.hitch(_d,_c);
39
return _a.replace(/\$\{([^\s\:\}]+)(?:\:([^\s\:\}]+))?\}/g,function(_f,key,_11){
40
var _12=dojo.getObject(key,false,_b);
41
if(_11){
42
_12=dojo.getObject(_11,false,_d).call(_d,_12,key);
43
}
44
return _c(_12,key).toString();
45
});
46
};
47
dojo.string.trim=function(str){
48
str=str.replace(/^\s+/,"");
49
for(var i=str.length-1;i>=0;i--){
50
if(/\S/.test(str.charAt(i))){
51
str=str.substring(0,i+1);
52
break;
53
}
54
}
55
return str;
56
};
57
}
(26-26/26)