sync
[roojs1] / docs / symbols / String.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
3
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
6         <head>
7                 <meta http-equiv="content-type" content="text/html; charset=undefined" />
8                 <meta name="generator" content="JsDoc Toolkit" />
9                 
10                 
11                 <title>JsDoc Reference - String</title>
12                 
13                 
14         <link rel="stylesheet" type="text/css" href="../../css/roojs.css" />            
15         <link rel="stylesheet" type="text/css" href="../default.css" />
16         
17         
18         <script type="text/javascript" src="../page.js">
19         
20         </script>
21          
22                 
23         </head>
24
25         <body onload="RooDocsPage.onload();">
26          
27         
28 <div class="body-wrap">
29
30     <!-- ============================== links to methods. ================================= --> 
31
32     <div class="top-tools">
33     <!--
34         <a class="inner-link" href="#String-props"><img src="resources/s.gif" class="item-icon icon-prop">Properties</a>
35         <a class="inner-link" href="#String-methods"><img src="resources/s.gif" class="item-icon icon-method">Methods</a>
36         <a class="inner-link" href="#String-events"><img src="resources/s.gif" class="item-icon icon-event">Events</a>
37         <a class="inner-link" href="#String-configs"><img src="resources/s.gif" class="item-icon icon-config">Config Options</a>
38         <a class="bookmark" href="NEED_TO_CREATE_DIRECT_LINK_HREF"><img src="resources/s.gif" class="item-icon icon-fav">Direct Link</a>
39         -->
40     </div>
41
42     
43 <!-- ============================== inheritance Block. ================================= -->    
44         
45 <!-- ============================== class title / details ============================ -->
46     
47     
48     <h1 class="classTitle">
49                                 
50                                 Built-In Class String
51                         </h1>
52                         
53     <table cellspacing="0" class="class-summary-table">
54         
55         <tr><td class="label">Defined In:</td><td class="hd-info">
56                         
57         </td></tr>
58         <tr><td class="label">Class:</td><td class="hd-info">String</td></tr>
59         
60         
61         
62         
63     </table>
64
65     
66 <!-- ============================== class summary ========================== -->                        
67     <div class="description">
68         
69     </div>
70
71         
72 <!-- ============================== Class comment block... ========================== -->                                       
73
74 <div class="comments">
75         <b>Class Comments / Notes</B> =>  
76         <u onclick="parent.CommentDialog.showCommentId = 'String';">[Add Your comment/notes about this class]</u>
77         <br/>
78         <iframe frameborder="0"  id="comments-" style="border: none;width:100%;" 
79                 src="/blog.php/GtkDjsComments/String.html"></iframe>
80 </div>
81         
82
83                 
84 <!-- ============================== config options ========================== -->                                               
85                  
86     
87     
88                 
89     <div class="hr"></div>
90     <a id="String-configs"></a>
91                 
92     
93     
94      <table cellspacing="0" class="member-table">
95       <caption class="Empty">Config Options - Has None</caption>
96      </table>
97     
98     
99      
100                 
101   
102   
103   
104   
105   
106   
107   
108   
109   <!-- ============================== public properties ==================== -->        
110   
111   
112   
113     <a id="String-props"></a>      
114     
115     
116
117     
118     
119      <table cellspacing="0" class="member-table">
120       <caption class="Empty">Public Properties - Has None</caption>
121      </table>
122     
123     
124      
125     
126   <!-- ============================== methods summary / details ======================== -->
127   
128   
129   <a id="String-methods"></a>
130         <!-- constructor?? -->
131         
132         <!-- static's first 
133         
134         
135         -->
136         
137         <!-- then dynamics first -->
138         
139   
140   
141     
142     
143     
144       <table cellspacing="0" class="member-table">
145       <caption>Public Methods</caption>
146         <tr>
147             <th class="sig-header" colspan="2">Method</th>            
148             <th class="msource-header">Defined By</th>
149
150         </tr>
151         
152         
153         
154          
155         
156         
157           
158           <tr class="method-row config-row-alt0 expandable notInherited">
159             <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
160            
161            
162             <td class="sig">
163                 <a id="String-method-escape"   name=".escape"></a>
164                 <div class="fixedFont">
165                         <span class="attributes">String.</span><b class="itemname">escape</b>
166                                 
167                                  (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>string</i></B>) 
168                         
169                                 
170                                          : 
171                                         
172                                                 
173                                                 <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>
174                                         
175                                         
176                                         
177                                 
178                         
179                 </div>
180                 <div class="mdesc">
181                 
182                    <div class="short">Escapes the passed string for ' and \</div> 
183                  
184                  
185                  
186                     <div class="long">
187                         
188                                 Escapes the passed string for ' and \
189                     
190                                 
191                         
192                         
193                         
194                         
195                                 <dl class="detailList">
196                                 <dt class="heading">Parameters:</dt>
197                                 
198                                         <dt>
199                                                 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span>  <b>string</b>
200                                                 
201                                         </dt>
202                                         <dd>The string to escape</dd>
203                                 
204                                 </dl>
205                         
206                         
207                         
208                         
209                         
210                                 <dl class="detailList">
211                                 <dt class="heading">Returns:</dt>
212                                 
213                                         <dd><span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span>  The escaped string</dd>
214                                 
215                                 </dl>
216                         
217                         
218                         
219
220                     
221                     
222                      
223                     </div>                    
224                 </div>
225
226             </td>
227             <td class="msource">
228                 
229                         String
230                 &nbsp;
231             </td>
232         </tr>
233         
234           
235           <tr class="method-row config-row-alt1 expandable notInherited">
236             <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
237            
238            
239             <td class="sig">
240                 <a id="String-method-format"   name=".format"></a>
241                 <div class="fixedFont">
242                         <span class="attributes">String.</span><b class="itemname">format</b>
243                                 
244                                  (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>string</i></B>, <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>value1</i></B>, <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>value2</i></B>) 
245                         
246                                 
247                                          : 
248                                         
249                                                 
250                                                 <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>
251                                         
252                                         
253                                         
254                                 
255                         
256                 </div>
257                 <div class="mdesc">
258                 
259                    <div class="short">Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.</div> 
260                  
261                  
262                  
263                     <div class="long">
264                         
265                                 Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.  Each<br/>token must be unique, and must increment in the format {0}, {1}, etc.  Example usage:<br/><pre><code><br/>var cls = 'my-class', text = 'Some text';<br/>var s = String.format('<div class="{0}">{1}</div>', cls, text);<br/>// s now contains the string: '<div class="my-class">Some text</div>'<br/></code></pre>
266                     
267                                 
268                         
269                         
270                         
271                         
272                                 <dl class="detailList">
273                                 <dt class="heading">Parameters:</dt>
274                                 
275                                         <dt>
276                                                 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span>  <b>string</b>
277                                                 
278                                         </dt>
279                                         <dd>The tokenized string to be formatted</dd>
280                                 
281                                         <dt>
282                                                 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span>  <b>value1</b>
283                                                 
284                                         </dt>
285                                         <dd>The value to replace token {0}</dd>
286                                 
287                                         <dt>
288                                                 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span>  <b>value2</b>
289                                                 
290                                         </dt>
291                                         <dd>Etc...</dd>
292                                 
293                                 </dl>
294                         
295                         
296                         
297                         
298                         
299                                 <dl class="detailList">
300                                 <dt class="heading">Returns:</dt>
301                                 
302                                         <dd><span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span>  The formatted string</dd>
303                                 
304                                 </dl>
305                         
306                         
307                         
308
309                     
310                     
311                      
312                     </div>                    
313                 </div>
314
315             </td>
316             <td class="msource">
317                 
318                         String
319                 &nbsp;
320             </td>
321         </tr>
322         
323           
324           <tr class="method-row config-row-alt0 expandable notInherited">
325             <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
326            
327            
328             <td class="sig">
329                 <a id="String-method-leftPad"   name=".leftPad"></a>
330                 <div class="fixedFont">
331                         <span class="attributes">String.</span><b class="itemname">leftPad</b>
332                                 
333                                  (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>string</i></B>, <a href="./Number.html#constructor" roo:cls="Number.html#constructor">Number</a> <B><i>size</i></B>, <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>char</i></B>) 
334                         
335                                 
336                                          : 
337                                         
338                                                 
339                                                 <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>
340                                         
341                                         
342                                         
343                                 
344                         
345                 </div>
346                 <div class="mdesc">
347                 
348                    <div class="short">Pads the left side of a string with a specified character.</div> 
349                  
350                  
351                  
352                     <div class="long">
353                         
354                                 Pads the left side of a string with a specified character.  This is especially useful<br/>for normalizing number and date strings.  Example usage:<br/><pre><code><br/>var s = String.leftPad('123', 5, '0');<br/>// s now contains the string: '00123'<br/></code></pre>
355                     
356                                 
357                         
358                         
359                         
360                         
361                                 <dl class="detailList">
362                                 <dt class="heading">Parameters:</dt>
363                                 
364                                         <dt>
365                                                 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span>  <b>string</b>
366                                                 
367                                         </dt>
368                                         <dd>The original string</dd>
369                                 
370                                         <dt>
371                                                 <span class="fixedFont"><a href="./Number.html#constructor" roo:cls="Number.html#constructor">Number</a></span>  <b>size</b>
372                                                 
373                                         </dt>
374                                         <dd>The total length of the output string</dd>
375                                 
376                                         <dt>
377                                                 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span>  <b>char</b>
378                                                 
379                                         </dt>
380                                         <dd>(optional) The character with which to pad the original string (defaults to empty string " ")</dd>
381                                 
382                                 </dl>
383                         
384                         
385                         
386                         
387                         
388                                 <dl class="detailList">
389                                 <dt class="heading">Returns:</dt>
390                                 
391                                         <dd><span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span>  The padded string</dd>
392                                 
393                                 </dl>
394                         
395                         
396                         
397
398                     
399                     
400                      
401                     </div>                    
402                 </div>
403
404             </td>
405             <td class="msource">
406                 
407                         String
408                 &nbsp;
409             </td>
410         </tr>
411         
412           
413           <tr class="method-row config-row-alt1 expandable notInherited">
414             <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
415            
416            
417             <td class="sig">
418                 <a id="String-method-toggle"   name=".toggle"></a>
419                 <div class="fixedFont">
420                         <span class="attributes"></span><b class="itemname">toggle</b>
421                                 
422                                  (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>value</i></B>, <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>other</i></B>) 
423                         
424                                 
425                                          : 
426                                         
427                                                 
428                                                 <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>
429                                         
430                                         
431                                         
432                                 
433                         
434                 </div>
435                 <div class="mdesc">
436                 
437                    <div class="short">Utility function that allows you to easily switch a string between two alternating values.</div> 
438                  
439                  
440                  
441                     <div class="long">
442                         
443                                 Utility function that allows you to easily switch a string between two alternating values.  The passed value<br/>is compared to the current string, and if they are equal, the other value that was passed in is returned.  If<br/>they are already different, the first value passed in is returned.  Note that this method returns the new value<br/>but does not change the current string.<br/><pre><code><br/>// alternate sort directions<br/>sort = sort.toggle('ASC', 'DESC');<br/><br/>// instead of conditional logic:<br/>sort = (sort == 'ASC' ? 'DESC' : 'ASC');<br/></code></pre>
444                     
445                                 
446                         
447                         
448                         
449                         
450                                 <dl class="detailList">
451                                 <dt class="heading">Parameters:</dt>
452                                 
453                                         <dt>
454                                                 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span>  <b>value</b>
455                                                 
456                                         </dt>
457                                         <dd>The value to compare to the current string</dd>
458                                 
459                                         <dt>
460                                                 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span>  <b>other</b>
461                                                 
462                                         </dt>
463                                         <dd>The new value to use if the string already equals the first value passed in</dd>
464                                 
465                                 </dl>
466                         
467                         
468                         
469                         
470                         
471                                 <dl class="detailList">
472                                 <dt class="heading">Returns:</dt>
473                                 
474                                         <dd><span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span>  The new value</dd>
475                                 
476                                 </dl>
477                         
478                         
479                         
480
481                     
482                     
483                      
484                     </div>                    
485                 </div>
486
487             </td>
488             <td class="msource">
489                 
490                         String
491                 &nbsp;
492             </td>
493         </tr>
494         
495                                                        
496     </table>
497
498   
499   <!-- ============================== events summary / details ======================== -->
500   
501   
502   <a id="String-events"></a>
503     
504   
505         
506    
507     
508      <table cellspacing="0" class="member-table">
509       <caption class="Empty">Events - Has None</caption>
510      </table>
511     
512     
513   
514     
515     
516   
517   
518   
519  
520 <!-- ============================== footer ================================= -->
521                 <div class="fineprint" style="clear:both">
522                         
523                         Documentation generated by <a href="http://www.akbkhome.com" target="_blankt">Introspection Doc Generator</a>  on Tue Jul 27 2010 11:05:09 GMT+0800 (HKT)
524                         Based on 
525                         <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a>  
526                 </div>
527         </body>
528 </html>