Anda di halaman 1dari 1

YUI Library: The YAHOO Global Object 2008-2-19 v2.

5
Simple Use Case: YAHOO Object YAHOO Object: Default Members YAHOO.lang Methods
See online docs for complete documentation on each default member of the YAHOO object. dump(obj or arr) returns string
In its simplest usage, the YAHOO global object requires no Member Type Description representation
implementer action; it serves as a container and provider of utility isArray(any) returns boolean
env object Environment object. Contains information about what isBoolean(any) returns boolean
methods to all other components of the YUI Library. YUI modules are loaded and provides a method for isFunction(any) returns boolean
obtaining version information. isNull(any) returns boolean
isNumber(any) returns boolean
Usage: YAHOO.namespace() example object An empty object used as a namespace for example
isObject(any) returns boolean
implementations.
isString(any) returns boolean
YAHOO.namespace(str namespace) lang object Contains utility methods. Full list at right. isUndefined(any) returns boolean
util object Namespace for YUI utilities. Do not add your own hasOwnProperty(obj, property)
Arguments: members to this object returns boolean
(1) namespace: A string containing a single namespace (e.g. tool object Namespace for developer tools like YUITest. Do not augmentObject() general mixin
“myproduct”) or a deeper namespace (e.g. function
add your own memebers to this object. augmentProto() see usage section
“myproduct.weatherModule”). Namespace objects are widget object Namespace for YUI controls (widgets). Do not add extend() see usage section
created within the YAHOO object. your own members to this object. isValue(any) returns false for
Note: Be careful when naming packages. JavaScript reserved words may work as property log method Calls YAHOO.widget.Logger.log; prevents log null/undefined/NaN, else true — note
that false has value and returns true
names in some browsers and not others. messages from throwing errors when the Logger merge(obj1, obj2, …) returns object
Control is not present. with all properties of all args
register method Registers a module with the YAHOO object. substitute() see docs
Usage: YAHOO.lang.augmentObject() trim(string) removes leading/trailing
YAHOO.lang.augmentObject(fn receiver, fn Usage: YAHOO.lang.extend() space

supplier[, str property1, str property2, … , YAHOO.env Method:


YAHOO.extend(obj subclass, obj superclass[, obj
str propertyn]) getVersion(str yuimodulename)
overrides]) returns module info; see below
Arguments:
Arguments:
(1) receiver: The object to be augmented.
(1) subclass: The object you're using to extend the base object. Module Info
(2) supplier: The object serving as the source of the
(2) superclass: The base object being extended by the "subclass". YAHOO.env.modules is an
augmentation.
(3) overrides: An object whose members will be added to the subclass object indexed by module
(3-n) properties: By default, YAHOO.lang.augmentObject will name; each member contains
prototype, overriding members of the same name if they exist on the
apply all members of the supplier object to the receiver if the information about a single YUI
superclass prototype.
receiver doesn’t already have them; arguments 3 through n module. Module info objects
contain the following
can be used to supply string member names that designate
the specific members to be augmented from the supplier to Solutions information:
name str module name
the receiver.
YAHOO_config is not included as part of the YUI library. Instead it is an version str last loaded
Note: The default operation, in which all of the supplier's members are applied to the receiver, version
YAHOO.lang.augment will avoid overwriting existing members on the receiver. If you specify
object that can be defined by the implementer immediately before build n last loaded build
supplier members to use for augmentation (via arguments 3 through n), the augmentation will including the YUI library. Use YAHOO_config to set up a listener that versions arr all loaded
overwrite those members if they already exist on the receiver. versions
fires when YUI components are loaded: builds arr all loaded builds
mainClass fn reference to main
var YAHOO_config = {
Usage: YAHOO.lang.augmentProto() listener: function(moduleInfo) {
class for this module

//executes when any YUI module loads, including YAHOO YUI module names: animation,
YAHOO.namespace(fn receiver, fn supplier[, str autocomplete, base, button,
object calendar, colorpicker, connection,
property1, str property2, … , str propertyn]) } container, containercore, datasource,
This function is symmetrical with YAHOO.lang.augmentObject } datatable, dom, dragdrop, editor,
element, event, fonts, grids, history,
(see above); however, it augments only from the supplier’s Note: See Module Info table at right for the format of object passed to your listener function. imageloader, logger, menu, reset,
slider, tabview, treeview, yahoo,
prototype to the receiver’s prototype. Instance members are not Get version information for a YUI component that has been loaded on yuiloader, yuitest.
copied from the supplier to the receiver. the page:
Dependencies var YAHOO.env.getVersion("animation"); //returns module info
object
The YAHOO Global Object is a dependency for all YUI components; it
has no dependencies of its own.

Anda mungkin juga menyukai