webgui/www/extras/yui/docs/YAHOO.lang.html
2008-03-25 16:13:25 +00:00

1355 lines
67 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>API: yahoo YAHOO.lang (YUI Library)</title>
<link rel="stylesheet" type="text/css" href="assets/api.css">
<script type="text/javascript" src="assets/api-js"></script>
<script type="text/javascript" src="assets/ac-js"></script>
</head>
<body id="yahoo-com">
<div id="doc3" class="yui-t2">
<div id="hd">
<a href="http://developer.yahoo.com/yui/"><h1>Yahoo! UI Library</h1></a>
<h3>YAHOO Global&nbsp; <span class="subtitle">2.5.1</span></h3>
<p>
<a href="./index.html">Yahoo! UI Library</a>
&gt; <a href="./module_yahoo.html">yahoo</a>
&gt; YAHOO.lang
</p>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form name="yui-classopts-form">
<span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> Show Private</span>
<span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> Show Protected</span>
</form>
<h2>
Class <b>YAHOO.lang</b>
<span class="extends">
</span>
<span class="extends">
</span>
</code>
</h2>
<!-- class tree goes here -->
<div class="summary description">
Provides the language utilites and extensions used by the library
</div>
<div class="section field details">
<h3 id="properties">Properties</h3>
<div class="content">
<div class="private">
<h4><a name="property__IEEnumFix">_IEEnumFix</a>
<code>- private static object</code>
</h4>
<div class="detail">
<div class="description">
IE will not enumerate native functions in a derived object even if the
function was overridden. This is a workaround for specific functions
we care about on the Object prototype.
</div>
</div>
<hr />
</div>
</div>
</div>
<div class="section method details">
<h3 id="methods">Methods</h3>
<div class="content">
<div class="">
<h4>
<a name="method_augment">augment</a></h4>
<div class="detail">
<code>
static
void
<strong>augment</strong>
(
r
,
s
,
arguments
)
</code>
<div class="description">
Same as YAHOO.lang.augmentObject, except it only applies prototype
properties. This is an alias for augmentProto.
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>r &lt;Function&gt;</code>
the object to receive the augmentation
</dd>
<dd>
<code>s &lt;Function&gt;</code>
the object that supplies the properties to augment
</dd>
<dd>
<code>arguments &lt;String*|boolean&gt;</code>
zero or more properties methods to
augment the receiver with. If none specified, everything
in the supplier will be used unless it would
overwrite an existing property in the receiver. if true
is specified as the third parameter, all properties will
be applied and will overwrite an existing property in
the receiver
</dd>
</dl>
<dl>
<dt>Returns:
<code>
void
</code></dt>
<dd></dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_augmentObject">augmentObject</a></h4>
<div class="detail">
<code>
static
void
<strong>augmentObject</strong>
(
r
,
s
,
arguments
)
</code>
<div class="description">
Applies all properties in the supplier to the receiver if the
receiver does not have these properties yet. Optionally, one or
more methods/properties can be specified (as additional
parameters). This option will overwrite the property if receiver
has it already. If true is passed as the third parameter, all
properties will be applied and _will_ overwrite properties in
the receiver.
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>r &lt;Function&gt;</code>
the object to receive the augmentation
</dd>
<dd>
<code>s &lt;Function&gt;</code>
the object that supplies the properties to augment
</dd>
<dd>
<code>arguments &lt;String*|boolean&gt;</code>
zero or more properties methods
to augment the receiver with. If none specified, everything
in the supplier will be used unless it would
overwrite an existing property in the receiver. If true
is specified as the third parameter, all properties will
be applied and will overwrite an existing property in
the receiver
</dd>
</dl>
<dl>
<dt>Returns:
<code>
void
</code></dt>
<dd></dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_augmentProto">augmentProto</a></h4>
<div class="detail">
<code>
static
void
<strong>augmentProto</strong>
(
r
,
s
,
arguments
)
</code>
<div class="description">
Same as YAHOO.lang.augmentObject, except it only applies prototype properties
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>r &lt;Function&gt;</code>
the object to receive the augmentation
</dd>
<dd>
<code>s &lt;Function&gt;</code>
the object that supplies the properties to augment
</dd>
<dd>
<code>arguments &lt;String*|boolean&gt;</code>
zero or more properties methods
to augment the receiver with. If none specified, everything
in the supplier will be used unless it would overwrite an existing
property in the receiver. if true is specified as the third
parameter, all properties will be applied and will overwrite an
existing property in the receiver
</dd>
</dl>
<dl>
<dt>Returns:
<code>
void
</code></dt>
<dd></dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_dump">dump</a></h4>
<div class="detail">
<code>
String
<strong>dump</strong>
(
o
,
d
)
</code>
<div class="description">
Returns a simple string representation of the object or array.
Other types of objects will be returned unprocessed. Arrays
are expected to be indexed. Use object notation for
associative arrays.
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>o &lt;Object&gt;</code>
The object to dump
</dd>
<dd>
<code>d &lt;int&gt;</code>
How deep to recurse child objects, default 3
</dd>
</dl>
<dl>
<dt>Returns:
<code>
String
</code></dt>
<dd>the dump result</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_extend">extend</a></h4>
<div class="detail">
<code>
static
void
<strong>extend</strong>
(
subc
,
superc
,
overrides
)
</code>
<div class="description">
Utility to set up the prototype, constructor and superclass properties to
support an inheritance strategy that can chain constructors and methods.
Static members will not be inherited.
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>subc &lt;Function&gt;</code>
the object to modify
</dd>
<dd>
<code>superc &lt;Function&gt;</code>
the object to inherit
</dd>
<dd>
<code>overrides &lt;Object&gt;</code>
additional properties/methods to add to the
subclass prototype. These will override the
matching items obtained from the superclass
if present.
</dd>
</dl>
<dl>
<dt>Returns:
<code>
void
</code></dt>
<dd></dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_hasOwnProperty">hasOwnProperty</a></h4>
<div class="detail">
<code>
boolean
<strong>hasOwnProperty</strong>
(
o
)
</code>
<div class="description">
Determines whether or not the property was added
to the object instance. Returns false if the property is not present
in the object, or was inherited from the prototype.
This abstraction is provided to enable hasOwnProperty for Safari 1.3.x.
There is a discrepancy between YAHOO.lang.hasOwnProperty and
Object.prototype.hasOwnProperty when the property is a primitive added to
both the instance AND prototype with the same value:
<pre>
var A = function() {};
A.prototype.foo = 'foo';
var a = new A();
a.foo = 'foo';
alert(a.hasOwnProperty('foo')); // true
alert(YAHOO.lang.hasOwnProperty(a, 'foo')); // false when using fallback
</pre>
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>o &lt;any&gt;</code>
The object being testing
</dd>
</dl>
<dl>
<dt>Returns:
<code>
boolean
</code></dt>
<dd>the result</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_isArray">isArray</a></h4>
<div class="detail">
<code>
boolean
<strong>isArray</strong>
(
o
)
</code>
<div class="description">
Determines whether or not the provided object is an array.
Testing typeof/instanceof/constructor of arrays across frame
boundaries isn't possible in Safari unless you have a reference
to the other frame to test against its Array prototype. To
handle this case, we test well-known array properties instead.
properties.
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>o &lt;any&gt;</code>
The object being testing
</dd>
</dl>
<dl>
<dt>Returns:
<code>
boolean
</code></dt>
<dd>the result</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_isBoolean">isBoolean</a></h4>
<div class="detail">
<code>
boolean
<strong>isBoolean</strong>
(
o
)
</code>
<div class="description">
Determines whether or not the provided object is a boolean
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>o &lt;any&gt;</code>
The object being testing
</dd>
</dl>
<dl>
<dt>Returns:
<code>
boolean
</code></dt>
<dd>the result</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_isFunction">isFunction</a></h4>
<div class="detail">
<code>
boolean
<strong>isFunction</strong>
(
o
)
</code>
<div class="description">
Determines whether or not the provided object is a function
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>o &lt;any&gt;</code>
The object being testing
</dd>
</dl>
<dl>
<dt>Returns:
<code>
boolean
</code></dt>
<dd>the result</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_isNull">isNull</a></h4>
<div class="detail">
<code>
boolean
<strong>isNull</strong>
(
o
)
</code>
<div class="description">
Determines whether or not the provided object is null
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>o &lt;any&gt;</code>
The object being testing
</dd>
</dl>
<dl>
<dt>Returns:
<code>
boolean
</code></dt>
<dd>the result</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_isNumber">isNumber</a></h4>
<div class="detail">
<code>
boolean
<strong>isNumber</strong>
(
o
)
</code>
<div class="description">
Determines whether or not the provided object is a legal number
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>o &lt;any&gt;</code>
The object being testing
</dd>
</dl>
<dl>
<dt>Returns:
<code>
boolean
</code></dt>
<dd>the result</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_isObject">isObject</a></h4>
<div class="detail">
<code>
boolean
<strong>isObject</strong>
(
o
)
</code>
<div class="description">
Determines whether or not the provided object is of type object
or function
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>o &lt;any&gt;</code>
The object being testing
</dd>
</dl>
<dl>
<dt>Returns:
<code>
boolean
</code></dt>
<dd>the result</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_isString">isString</a></h4>
<div class="detail">
<code>
boolean
<strong>isString</strong>
(
o
)
</code>
<div class="description">
Determines whether or not the provided object is a string
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>o &lt;any&gt;</code>
The object being testing
</dd>
</dl>
<dl>
<dt>Returns:
<code>
boolean
</code></dt>
<dd>the result</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_isUndefined">isUndefined</a></h4>
<div class="detail">
<code>
boolean
<strong>isUndefined</strong>
(
o
)
</code>
<div class="description">
Determines whether or not the provided object is undefined
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>o &lt;any&gt;</code>
The object being testing
</dd>
</dl>
<dl>
<dt>Returns:
<code>
boolean
</code></dt>
<dd>the result</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_isValue">isValue</a></h4>
<div class="detail">
<code>
boolean
<strong>isValue</strong>
(
o
)
</code>
<div class="description">
A convenience method for detecting a legitimate non-null value.
Returns false for null/undefined/NaN, true for other values,
including 0/false/''
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>o &lt;any&gt;</code>
the item to test
</dd>
</dl>
<dl>
<dt>Returns:
<code>
boolean
</code></dt>
<dd>true if it is not null/undefined/NaN || false</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_later">later</a></h4>
<div class="detail">
<code>
void
<strong>later</strong>
(
when
,
o
,
fn
,
data
,
periodic
)
</code>
<div class="description">
Executes the supplied function in the context of the supplied
object 'when' milliseconds later. Executes the function a
single time unless periodic is set to true.
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>when &lt;int&gt;</code>
the number of milliseconds to wait until the fn
is executed
</dd>
<dd>
<code>o &lt;object&gt;</code>
the context object
</dd>
<dd>
<code>fn &lt;Function|String&gt;</code>
the function to execute or the name of
the method in the 'o' object to execute
</dd>
<dd>
<code>data &lt;object&gt;</code>
[Array] data that is provided to the function. This accepts
either a single item or an array. If an array is provided, the
function is executed with one parameter for each array item. If
you need to pass a single array parameter, it needs to be wrapped in
an array [myarray]
</dd>
<dd>
<code>periodic &lt;boolean&gt;</code>
if true, executes continuously at supplied
interval until canceled
</dd>
</dl>
<dl>
<dt>Returns:
<code>
void
</code></dt>
<dd>a timer object. Call the cancel() method on this object to
stop the timer.</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_merge">merge</a></h4>
<div class="detail">
<code>
void
<strong>merge</strong>
(
arguments
)
</code>
<div class="description">
Returns a new object containing all of the properties of
all the supplied objects. The properties from later objects
will overwrite those in earlier objects.
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>arguments &lt;Object*&gt;</code>
the objects to merge
</dd>
</dl>
<dl>
<dt>Returns:
<code>
void
</code></dt>
<dd>the new merged object</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_substitute">substitute</a></h4>
<div class="detail">
<code>
String
<strong>substitute</strong>
(
s
,
o
,
f
)
</code>
<div class="description">
Does variable substitution on a string. It scans through the string
looking for expressions enclosed in { } braces. If an expression
is found, it is used a key on the object. If there is a space in
the key, the first word is used for the key and the rest is provided
to an optional function to be used to programatically determine the
value (the extra information might be used for this decision). If
the value for the key in the object, or what is returned from the
function has a string value, number value, or object value, it is
substituted for the bracket expression and it repeats. If this
value is an object, it uses the Object's toString() if this has
been overridden, otherwise it does a shallow dump of the key/value
pairs.
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>s &lt;String&gt;</code>
The string that will be modified.
</dd>
<dd>
<code>o &lt;Object&gt;</code>
An object containing the replacement values
</dd>
<dd>
<code>f &lt;Function&gt;</code>
An optional function that can be used to
process each match. It receives the key,
value, and any extra metadata included with
the key inside of the braces.
</dd>
</dl>
<dl>
<dt>Returns:
<code>
String
</code></dt>
<dd>the substituted string</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_trim">trim</a></h4>
<div class="detail">
<code>
string
<strong>trim</strong>
(
s
)
</code>
<div class="description">
Returns a string without any leading or trailing whitespace. If
the input is not a string, the input will be returned untouched.
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>s &lt;string&gt;</code>
the string to trim
</dd>
</dl>
<dl>
<dt>Returns:
<code>
string
</code></dt>
<dd>the trimmed string</dd>
</dl>
</div>
</div>
<hr />
</div>
</div>
</div>
</div>
</div>
<div class="yui-b">
<div class="nav">
<div class="module">
<h4>Modules</h4>
<ul class="content">
<li class=""><a href="module_animation.html">animation</a></li>
<li class=""><a href="module_autocomplete.html">autocomplete</a></li>
<li class=""><a href="module_button.html">button</a></li>
<li class=""><a href="module_calendar.html">calendar</a></li>
<li class=""><a href="module_charts.html">charts</a></li>
<li class=""><a href="module_colorpicker.html">colorpicker</a></li>
<li class=""><a href="module_connection.html">connection</a></li>
<li class=""><a href="module_container.html">container</a></li>
<li class=""><a href="module_cookie.html">cookie</a></li>
<li class=""><a href="module_datasource.html">datasource</a></li>
<li class=""><a href="module_datatable.html">datatable</a></li>
<li class=""><a href="module_dom.html">dom</a></li>
<li class=""><a href="module_dragdrop.html">dragdrop</a></li>
<li class=""><a href="module_editor.html">editor</a></li>
<li class=""><a href="module_element.html">element</a></li>
<li class=""><a href="module_event.html">event</a></li>
<li class=""><a href="module_get.html">get</a></li>
<li class=""><a href="module_history.html">history</a></li>
<li class=""><a href="module_imagecropper.html">imagecropper</a></li>
<li class=""><a href="module_imageloader.html">imageloader</a></li>
<li class=""><a href="module_json.html">json</a></li>
<li class=""><a href="module_layout.html">layout</a></li>
<li class=""><a href="module_logger.html">logger</a></li>
<li class=""><a href="module_menu.html">menu</a></li>
<li class=""><a href="module_profiler.html">profiler</a></li>
<li class=""><a href="module_profilerviewer.html">profilerviewer</a></li>
<li class=""><a href="module_resize.html">resize</a></li>
<li class=""><a href="module_selector.html">selector</a></li>
<li class=""><a href="module_slider.html">slider</a></li>
<li class=""><a href="module_tabview.html">tabview</a></li>
<li class=""><a href="module_treeview.html">treeview</a></li>
<li class=""><a href="module_uploader.html">uploader</a></li>
<li class="selected"><a href="module_yahoo.html">yahoo</a></li>
<li class=""><a href="module_yuiloader.html">yuiloader</a></li>
<li class=""><a href="module_yuitest.html">yuitest</a></li>
</ul>
</div>
<div class="module">
<h4>Classes</h4>
<ul class="content">
<li class=""><a href="YAHOO.html">YAHOO</a></li>
<li class=""><a href="YAHOO.env.html">YAHOO.env</a></li>
<li class=""><a href="YAHOO.env.ua.html">YAHOO.env.ua</a></li>
<li class="selected"><a href="YAHOO.lang.html">YAHOO.lang</a></li>
<li class=""><a href="YAHOO_config.html">YAHOO_config</a></li>
</ul>
</div>
<div class="module">
<h4>Files</h4>
<ul class="content">
<li class=""><a href="Env.js.html">Env.js</a></li>
<li class=""><a href="Lang.js.html">Lang.js</a></li>
<li class=""><a href="YAHOO.js.html">YAHOO.js</a></li>
</ul>
</div>
<div class="module">
<h4>Properties</h4>
<ul class="content">
<li class="private"><a href="#property__IEEnumFix">_IEEnumFix</a>
<!--<code>&lt;object&gt;</code>-->
</li>
</ul>
</div>
<div class="module">
<h4>Methods</h4>
<ul class="content">
<li class=""><!--<code>void</code>-->
<a href="#method_augment">augment</a>
</li>
<li class=""><!--<code>void</code>-->
<a href="#method_augmentObject">augmentObject</a>
</li>
<li class=""><!--<code>void</code>-->
<a href="#method_augmentProto">augmentProto</a>
</li>
<li class=""><!--<code>String</code>-->
<a href="#method_dump">dump</a>
</li>
<li class=""><!--<code>void</code>-->
<a href="#method_extend">extend</a>
</li>
<li class=""><!--<code>boolean</code>-->
<a href="#method_hasOwnProperty">hasOwnProperty</a>
</li>
<li class=""><!--<code>boolean</code>-->
<a href="#method_isArray">isArray</a>
</li>
<li class=""><!--<code>boolean</code>-->
<a href="#method_isBoolean">isBoolean</a>
</li>
<li class=""><!--<code>boolean</code>-->
<a href="#method_isFunction">isFunction</a>
</li>
<li class=""><!--<code>boolean</code>-->
<a href="#method_isNull">isNull</a>
</li>
<li class=""><!--<code>boolean</code>-->
<a href="#method_isNumber">isNumber</a>
</li>
<li class=""><!--<code>boolean</code>-->
<a href="#method_isObject">isObject</a>
</li>
<li class=""><!--<code>boolean</code>-->
<a href="#method_isString">isString</a>
</li>
<li class=""><!--<code>boolean</code>-->
<a href="#method_isUndefined">isUndefined</a>
</li>
<li class=""><!--<code>boolean</code>-->
<a href="#method_isValue">isValue</a>
</li>
<li class=""><!--<code>void</code>-->
<a href="#method_later">later</a>
</li>
<li class=""><!--<code>void</code>-->
<a href="#method_merge">merge</a>
</li>
<li class=""><!--<code>String</code>-->
<a href="#method_substitute">substitute</a>
</li>
<li class=""><!--<code>string</code>-->
<a href="#method_trim">trim</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div id="ft">
<hr />
Copyright &copy; 2007 Yahoo! Inc. All rights reserved.
</div>
</div>
</body>
</html>