Академический Документы
Профессиональный Документы
Культура Документы
Other:
Constructor: YAHOO.widget.Carousel Solutions resets calendar to original state
carousel.set
YAHOO.widget.Carousel([str container,] [,obj config]); Basic markup for a Carousel:
(propName, propValue)
Arguments: <div id="container"> carousel. get
(1) container: HTML ID or HTMLElement of existing markup to use <ul> (propName)
<li><img alt="" src="..."></li>
when building Carousel. This should be a UL or an OL element. </ul>
(2) Configuration Object: JS object defining configuration properties </div>
for the Carousel instance. See Configuration section and online
Render a Carousel that scrolls automatically every two seconds and animating
docs for a list of these options.
while scrolling:
carousel = new YAHOO.widget.Carousel("container", {
Carousel Options autoPlay: 2000, animation: { speed: 0.5 }
Configure options using the constructor configuration object or set(), as described in “Solutions” });
carousel.render();
Carousel objects include several configurable options, including:
There are two ways to configure options on your Carousel:
animation isCircular numVisible
autoPlay isVertical revealAmount // 1. In the constructor, via an object literal:
carousel = new YAHOO.widget.Carousel("container", {
isCircular: true
Dependencies });
Carousel requires YAHOO, Dom, Event and Element. // 2. Via "set":
carousel.set("isCircular", true);
YUI Library: Charts 2009-2-6 v2.7
Simple Use Case: YAHOO.widget.LineChart Key Interesting Moments in Charts YAHOO.widget.Axis
See online docs for a complete list of Charts Events. Properties
Markup: Event: Arguments: type
itemClickEvent, args.type (String) orientation
<div id="myContainer"> itemDoubleClickEvent, args.item (Object) reverse
<-- For progressive enhancement, it’s best to put itemMouseOverEvent, args.index (Number) labelFunction
the chart’s data here in tabular or textual form to itemMouseOutEvent args.seriesIndex (Number) hideOverlappingLabels
support viewers with Flash disabled. --> args.x (Number)
</div> args.y (Number) YAHOO.widget.NumericAxis
Script: itemDragStartEvent, args.type (String) Properties
itemDragEvent, args.item (Object) minimum
var mySeriesDef = [
itemDragUpdateEvent args.index (Number) maximum
{yField: "field1", displayName: "Series 1"},
{yField: "field2", displayName: "Series 2"}, args.seriesIndex (Number) majorUnit
...]; args.x (Number) minorUnit
var myDataSource = args.y (Number) snapToUnits
new YAHOO.util.DataSource([...]); alwaysShowZero
var myChart = new YAHOO.widget.LineChart( All Charts events are Custom Events (see Event Utility docs); subscribe to these events scale
"myContainer", myDataSource, {} ); using “subscribe”: (e.g. myChart.subscribe("itemClickEvent", handler); ).
Note: Refer to online documentation for
a full list of Axis properties.
Creates a Chart instance from scratch. Key Charts Configuration Options
See online docs for complete list of Charts configuration options. YAHOO.widget.Series
Option (type) Default Description Properties
xField (s) null The field used to access data to position
yField (s) items along the x or y axis. type
request (s) "" Request value to send to DataSource at displayName
instantiation for data to populate the chart.
series (a) null A series definition object. YAHOO.widget.CartesianSeries
dataTipFunction see docs Object literal of pagination values. Properties
(s)
Constructor: YAHOO.util.DataSource xAxis (o) null Custom axis objects. xField
yAxis (o) yField
YAHOO.util.DataSource(str|array|obj|HTMLFunction
|HTMLTable live data[, obj config]); polling (n) null The number of milliseconds between
requests to the DataSource object for new YAHOO.widget.PieSeries
Arguments: data. Properties
(1) live data: Pointer to a set of data. categoryNames (a) null If the DataSource does not contain a field
that may be used with a category axis, an dataField
(2) configuration object: An optional object literal defines property categoryField
values of a DataSource instance. Array of Strings may be substituted.
dataSource null Replace the current DataSource Note: Refer to online documentation for
a full list of Series properties.
wmode “window” The window mode of Flash Player. May be
Constructor: YAHOO.widget.ColumnChart “window”, “opaque” or “transparent”.
YAHOO.widget.ColumnChart(str element, obj DataSource[,
Charts options can be set in the constructor's third argument (e.g., {xField: "month"}) or at Dependencies
runtime via set (e.g., myChart.set("xField", "month");).
obj config]);
Charts require the YAHOO
Arguments: Solutions Global Object, Event Utility,
Dom Collection, Element
(1) element: HTML ID for a Chart container. May be empty or contain Specify a custom axis dimension if you don’t want the chart to size the axis by Utility, JSON Utility and
alternative content. default: DataSource Utility. Note:
(2) DataSource: DataSource instance.
On the client, Charts
(3) configuration object: An optional object literal defines property var axisWithMinimum = new YAHOO.widget.NumericAxis(); requires Flash Player 9.0.45
values of a Chart instance. axisWithMinimum.minimum = 800; or later.
myChart.set( "yAxis", axisWithMinimum );
YUI Library: Color Picker Control 2009-2-6 v2.7
Simple Use Case: YAHOO.widget.ColorPicker Interesting Moment in Color Picker YAHOO.widget.ColorPicker:
This is the full list of Custom Events exposed in the Color Picker API. Methods
Markup: Event: Event Fields:
<div id="picker"></div> getElement(id | key element)
rgbChange newValue (arr) and oldValue (arr), in both cases an returns the requested element; see API docs
Script: array of RGB values; type (s), "rgbChange". for keyset…pass in YUI_PICKER to return
the host element for the instance
var oPicker = new All Color Picker events are Custom Events (see Event Utility docs); subscribe to these events setValue(arr RGB[, b silent]) sets
YAHOO.widget.ColorPicker("picker", { using “addListener” or "on": (e.g. oPicker.on('rgbChange', fn); ). the currently selected color
showhsvcontrols: true,
showhexcontrols: true Key Color Picker Configuration Options YAHOO.widget.
); See online docs for complete list of Color Picker configuration options.
Option (type) Default Description ColorPicker: Form Fields
Creates a Color Picker instance from script; the Color Picker's
DOM structure is created in the element whose ID is "picker". showcontrols (b) true Hide/show the entire set of controls. When a form wrapping a Color Picker
instance is submitted, the following
showhexcontrols (b) true Hide/show the hex controls. form fields are included:
showhexsummary (b) true Hide/show the hexadecimal
summary information. yui-picker-r RGB red
yui-picker-g RGB green
showhsvcontrols (b) false Hide/show the HSV controls.
yui-picker-b RGB bluee
showrgbcontrols (b) true Hide/show the RGB controls. yui-picker-h HSV hue
showwebsafe (b) true Hide/show the websafe swatch. yui-picker-s HSV
images (o) Default Object Members: saturation
images PICKER_THUMB: Image
served by
yui-picker-v HSV value/
Y! servers representing the draggable thumb brightness
for the color region slider. yui-picker- Hex triplet for
HUE_THUMB: Image representing hex current color
the draggable thumb for the HSV
slider. Dependencies
Color Picker options can be set in the constructor's second argument (eg,
{showwebsafe: false}) or at runtime via set (eg, oPicker.set("showwebsafe", Color Picker requires
Constructor: YAHOO.widget.ColorPicker false);). Yahoo, Dom, Event,
Element, Drag & Drop,
YAHOO.widget.ColorPicker(str ID|HTMLElement Solutions and Slider. For the
element[, obj config]);
richest interaction, the
Arguments: Listen for the rgbChange event and make use of the event's fields:
optional Animation
(1) Element: HTML ID or HTMLElement for container element; var oPicker = new Utility is highly
this is the location in the DOM where the Color Picker Control YAHOO.widget.ColorPicker("container"); recommended.
will be inserted. //a listener for logging RGB color changes;
(2) Configuration Object: JS object defining configuration //this will only be visible if logger is enabled:
properties for the Color Picker instance. See Configuration var onRgbChange = function(o) {
Options section for full list. /*o is an object
{ newValue: (array of R, G, B values),
Setting the Color Picker's Value prevValue: (array of R, G, B values),
type: "rgbChange"
You can set the Color Picker's current value by script any time }
after instantiation using setValue: */
YAHOO.log("The new color value is " + o.newValue,
oPicker.setValue([255, 255, 255], false);
"info", "example");
The second argument is a boolean; if true, it suppresses the }
rgbChange event that would otherwise be fired when the value is //subscribe to the rgbChange event;
changed. oPicker.on("rgbChange", onRgbChange);
YUI Library: Connection Manager 2009-2-13 v2.7
Simple Use Case Global Custom Events Key methods of
These events fire for all transactions; subscribe via YAHOO.util.Connect; e.g.: YAHOO.util.Connect:
var callback = { YAHOO.util.Connect.startEvent.subscribe(myFn);
(o = Transaction object)
success: function(o) {
document.getElementById(‘someEl’).innerHTML = Event Fires when... Arguments abort(o)
o.responseText; startEvent transaction begins transaction ID asyncRequest()
} initHeader(s label, s
} completeEvent transaction complete, but not yet transaction ID
reconciled as success or failure value, [b persistHeader])
optional param persists header as a
var connectionObject = default for each subsequent
YAHOO.util.Connect.asyncRequest('GET', ‘file.php’, successEvent HTTP 2xx response received Response object
transaction.
callback); failureEvent HTTP 4xx, 5xx, or unknown Response object isCallInProgress(o)
response received setForm(str formId | o
Executes an asynchronous connection to file.php. If the HTTP status of the
response indicates success, the full text of the HTTP response is placed in a abortEvent timeout/abort succeeds transaction ID form el ref[, b isUpload,
page element whose ID attribute is “someEl”. s secureUri]) optional params
Response Object for file upload only; provide secureUri
for iFrame only under SSL
Invocation (asyncRequest) Your success, failure, and upload handlers are passed a single argument; that argument setPollingInterval(int i)
is an object with the following members: setProgId(id)
YAHOO.util.Connect.asyncRequest(str http method, str url[, tId The transaction id.
obj callback object, str POST body]); status The HTTP status code of the request. HTTP Status Codes
Arguments: statusText The message associated with the HTTP status.
getResponse Array collection of response headers and their corresponding
(1) HTTP method (string): GET, POST, HEAD, PUT, DELETE, etc. PUT and 2xx Successful
Header[] values, indexed by header label.
DELETE are not supported across all A-Grade browsers. getAllResponse String containing all available HTTP headers with name/value pairs 3xx Redirection
(2) URL (string): A url referencing a file that shares the same server DNS Headers delimited by "\n". 4xx Client error
name as the current page URL. responseText The server’s full response as a string; for upload, the contents of
(3) Callback (object): An object containing success and failure handlers and the response's <body> tag. 5xx Server error
arguments and a scope control; see Callback Object detail for more. responseXML If a valid XML document was returned and parsed successfully by
(4) POST body (string): If you are POSTing data to the server, this string holds the XHR object, this will be the resulting DOM object. 0 Communication
the POST message body. argument The arguments you defined in the Callback object's argument failure
Returns: Transaction object. { tId: int transaction id } The member.
200 OK
transaction object allows you to interact (via Connection Manager) with your
400 Bad request
XHR instance; pass tId to CM methods such as abort(). Solutions 401 Unauthorized
403 Forbidden
Callback Object: Members (All Optional) Roll up an existing form on the page, posting its data to the server:
404 Not found
YAHOO.util.Connect.setForm('formId');
1. customevents: Object containing any Custom Event handlers for var cObj = YAHOO.util.Connect.asyncRequest('POST',
408 Request timeout
transaction-level events (as alternatives to success and failure handlers 'formProcessor.php', callback); 410 Gone
below). Transaction-level Custom Events include onStart, onComplete, 500 Internal server
onSuccess, onFailure, onAbort and receive the same arguments as their Cancel a transaction in progress:
error
global counterparts (see Global Custom Events, above right). //if the transaction is created as follows... 502 Bad gateway
2. success (fn): The success method is called when an asyncRequest is var cObj = YAHOO.util.Connect.asyncRequest(‘GET’,
replied to by the server with an HTTP in the 2xx range; use this function to myServer.php', callback); 503 Service unavailable
process the response. //...then you would attempt to abort it this way:
3. failure (fn): The failure method is called when asyncRequest gets an YAHOO.util.Connect.abort(cObj);
HTTP status of 400 or greater. Use this function to handle unexpected
Connection Manager sets headers automatically for GET and POST
application/communications failures.
transactions. If you need to set a header manually, use this syntax:
4. argument (various): The argument member can be an object, array,
integer or string; it contains information to which your success and failure YAHOO.util.Connect.initHeader('SOAPAction', 'myAction');
handlers need access.
5. scope (obj): The object in whose scope your handlers should run.
6. timeout (int): Number of milliseconds CM should wait on a request before Dependencies
aborting and calling failure handler. Connection Manager requires the YAHOO Global Object and the Event Utility.
7. upload (fn): Handler to process file upload response.
YUI Library: Cookie Utility 2009-2-6 v2.7
Simple Use Case: Reading/writing a cookie Cookie Options Object YAHOO.util.Cookie
Options that can be set on the options object in remove(), set(), removeSub(), setSub(), and setSubs(). Cookie Methods
var value = YAHOO.util.Cookie.get("name"); Member Type Description get(str name, func converter) returns
expires Date A Date object representing the date and time at which a cookie value
Retrieves the cookie named “name” and stores its value in a the cookie should expire. set(str name, str value, obj options)
sets a cookie
variable. domain string The domain for which the cookie should be accessible. remove(str name, obj options) removes
path string The path for which the cookie should be accessible. a cookie
YAHOO.util.Cookie.set("name", "value"); secure boolean Indicates if the cookie is accessible only via SSL.
YAHOO.util.Cookie
Sets a cookie named “name” and stores “value” in it. Usage: YAHOO.util.Cookie.getSub() Subcookie Methods
var value = YAHOO.util.Cookie.getSub(str name, str getSub(str name, str subname, func
Usage: YAHOO.util.Cookie.get() subname [, func converter])
converter) returns a subcookie value
getSubs(str name) returns all subcookies
in an object
var value = YAHOO.util.Cookie.get(str name[, Arguments: setSub(str name, str subname, str
func converter]) (1) name: The name of the cookie to get. value, obj options) sets a subcookie
Arguments: (2) subname: The subcookie name to get. setSubs(str name, obj subcookies,
obj options) sets all subcookies in a
(1) name: The name of the cookie to get. (3) converter: (Optional) A conversion function to run the value through cookie
(2) converter: (Optional) A conversion function to run the value before returning it. This function is not called if the subcookie with the removeSub(str name, str subname,
through before returning it. This function is not called if the given name doesn’t exist. obj options) removes a subcookie
YAHOO.util.Cookie.set(str name, str value [, obj YAHOO.util.Cookie.setSub(str name, str subname, str
options]) value [, obj options])
Arguments: Arguments:
(1) name: The name of the cookie to set. (1) name: The name of the cookie to set.
(2) value: The value of the cookie to set. (2) subname: The subcookie name to set.
(3) options: (Optional) Options for setting the accessibility of the (3) value: The value for the subcookie.
cookie based on expiration date, domain, path, and security. (4) options: (Optional) Options for setting the accessibility of the cookie
based on expiration date, domain, path, and security.
YUI Library: CSS Reset, Base, Fonts, and Grids 2009-2-6 v2.7
Recommended Doctype and Render Mode YUI CSS Grids: Nomenclature Fonts Sizing Chart
#doc – Define the overall width of the page. For Use this
YUI works in both “Quirks” and “Standards/Strict” browser-
#doc4 doc 750px, doc2 950px, doc3 100%, doc4 974px, this PX percentage:
rendering modes, but we suggest using Standards mode by
.yui-t1 – Six preset template for secondary column size & side. 10 77
specifying this Doctype:
.yui-t6 (see right column, bottom chart) 11 85
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” .yui-g Basic grid (.yui-g) tells two units (.yui-g) to share. 12 93
“http://www.w3.org/TR/html4/strict.dtd”> 13 100
.yui-gb – Special grids (.yui-gb ... .yui-gf) are for three-
14 108
.yui-gf unit and uneven two-unit space sharing. 15 116
YUI CSS Reset + YUI CSS Base (see right column, middle chart) 16 123.1
.yui-u A unit inside a grid; generic; obeys parent grid. 17 131
YUI CSS Reset neutralizes browser CSS styles for HTML
elements, creating a normalized platform. YUI CSS Base then .first Overload the class attribute with “first” to indicate first 18 138.5
rebuilds a consistent style foundation for common HTML elements. of a series of grids or units. (This facilitate floats and 19 146.5
margins.) 20 153.9
YUI CSS Base is also useful as a snippets library, for instance to
21 161.6
see how to put bullets back on UL LIs.
Customize Page Width 22 167
23 174
YUI CSS Fonts: Setting Font Size and Family Pixels / 13 = width in ems. For IE, pixels / 13.333. Use star- 24 182
property filter to target IE. For example, this sets 610px: 25 189
Font-size: While still allowing users to zoom their font sizes, the #custom-doc { 26 197
YUI Fonts package renders all text at 13px by default. To preserve width:46.923em; /* 610/13 */
users’ ability to zoom their fonts, specify other sizes using *width:45.750em;/* 610/13.3333 */ Grids: Nesting Grids
percentages only (see top chart in right column). } (yui-g’s)
selector {font-size:123.1%;} /*16px*/ .yui-g 1/2, 1/2
Font-family: The YUI Fonts package defines Arial as the default
The Basic Grid Pattern .yui-gb 1/3, 1/3, 1/3
font and provides a degradation path through several alternate <div class="yui-g">
.yui-gc 2/3, 1/3
fonts down to the generic “sans-serif.” When specifying other font <div class="yui-u first"></div> .yui-gd 1/3, 2/3
families, provide your own degradation path as needed. <div class="yui-u"></div> .yui-ge 3/4, 1/4
</div> .yui-gf 1/4, 3/4
<style>selector {font-family:verdana,sans-
serif;}</style> Other configurations, such
as !, !, !, ! can be
The Nested Grid Pattern
rendered by nesting yui-g’s
Base Page Format <div class="yui-g"> inside other “yui-g” grids.
We find it useful to build a page in three stacked horizontal regions: <div class="yui-g first">
<div class="yui-u first"></div> Grids: Templates
<body> <div class="yui-u"></div>
<div id=”doc”><!—-overall document wrapper--> (yui-t’s)
</div>
<div id=”hd”><!--header / masthead--></div> <div class="yui-g"> .yui-t1 160 on left
<div id=”bd”><!--body--></div> <div class="yui-u first"></div> .yui-t2 180 on left
<div id=”ft”><!--footer--></div> <div class="yui-u"></div>
</div>
.yui-t3 300 on left
</div>
</body> .yui-t4 180 on right
</div>
.yui-t5 240 on right
Inside #bd, if two blocks (.yui-b) exist, designate a main block by .yui-t6 300 on right
wrapping it with <div id=”yui-main”>:
<div id=”yui-main”>
<div class=”yui-b”><!--primary--></div>
</div>
<div class=”yui-b”><!--secondary--></div>
YUI Library: DataSource 2009-2-17 v2.7
Simple Use Case Interesting Moments YAHOO.util.
Event oArgs passed to handler
DataSourceBase
Script: Properties:
var myDataSource = new YAHOO.util.DataSource cacheFlushEvent none
([{name:"a",id:"1"}, {name:"b",id:"2"}]); oArgs.request {obj} The request object dataType (int)
myDataSource.responseType = cacheRequestEvent
oArgs.callback {obj} The callback object liveData (mixed)
YAHOO.util.DataSource.TYPE_JSARRAY;
oArgs.request {obj} The request object responseSchema (obj)
myDataSource.responseSchema = [fields:["name","id"];
cacheResponseEvent oArgs.response {obj} The response object responseType (int)
Instantiates a new DataSource object, myDataSource, which manages data oArgs.callback {obj} The callback object
retrieval for use by other widgets. oArgs.request {obj} The request object YAHOO.util.XHRDataSourc
dataErrorEvent oArgs.callback {obj} The callback object e Properties:
Constructors oArgs.message {str} Error message
connMethodPost (b)
oArgs.request {obj} The request object
YAHOO.util.LocalDataSource(mixed data[, obj connMgr
configurations]); requestEvent oArgs.callback {obj} The callback object
(YAHOO.util.Connectio
oArgs.tId {int} Unique transaction ID
(1) data (array): A JavaScript array of strings. n)
oArgs.request {obj} The request object
(2) Configuration object (object): An optional object literal defines property connTimeout (int)
values of a DataSource instance. responseCacheEvent oArgs.response {obj} The response object
connXhrMode
oArgs.callback {obj} The callback object
YAHOO.util.FunctionDataSource(fn function[, obj ("queueRequests" |
configurations]); oArgs.request {obj} The request object "cancelStaleRequests" |
oArgs.response {obj} The response object ignoreStaleResponses"
(1) JS Function (fn): A JavaScript function which returns an array of strings. responseEvent
oArgs.callback {obj} The callback object | "allowAll")
(2) Configuration object (object): See above.
oArgs.tId {int} Unique transaction ID
YAHOO.util.ScriptNodeDataSource(str uri[, obj oArgs.request {obj} The request object
configurations]); YAHOO.util.ScriptNodeDat
responseParseEvent oArgs.response {obj} The response object
(1) URI: URI to the script location that will return data. oArgs.callback {obj} The callback object
aSource Properties:
(2) Schema (array): Schema description of server response data. Subscribe to DataSource Custom Events on your DataSource instance: asyncMode
(3) Configuration object (object): See above. myDS.subscribe("requestEvent", myFn); ("ignoreStaleResponse
YAHOO.util.XHRDataSource(str uri[, obj configurations]); s" | "allowAll")
Abstract Methods getUtility
(1) Script URI (string): Server URI (local domains only – use a proxy for
remote domains). Method Description (YAHOO.util.Get)
(2) Schema (array): Schema description of server response data. This overridable abstract method gives scriptCallbackParam
(3) Configuration object (object): See above. implementers an opportunity to access the (str)
YAHOO.util.DataSource(mixed data[, obj configurations]); data before it has been cached or returned
doBeforeCallback
to the callback. Implementers should be
(1) Script URI (string): Server URI (local domains only – use a proxy for
sure to return data in a ready-to-return state
remote domains).
(2) Schema (array): Schema description of server response data. to avoid errors.
(3) Configuration object (object): See above. This overridable abstract method gives
implementers an opportunity to munge the
doBeforeParseData data before it is schema-parsed.
Key Configuration Properties
Implementers should be sure to return data
Property Description in a ready-to-parse state to avoid errors.
Determines which parsing algorithm to
responseType
use on response data. Dependencies
Determines what data gets parsed out
responseSchema DataSource requires the YAHOO Global Object and the Event Utility.
of response for consumption.
Connection Manager (for XHRDataSource), the Get Utility (for
ScriptNodeDataSource), and the JSON Utility (for JSON data) are
optional.
YUI Library: DataSource 2009-2-17 v2.7
Data Flow in DataSource
YUI Library: DataTable 2009-2-6 v2.7
Simple Use Case: YAHOO.widget.DataTable Key Interesting Moments in DataTable YAHOO.widget.Column:
Not all event types are available for all elements and units. See online docs for full list of DataTable Events. Properties
Markup (container can be empty or pre-populated for progressive Event oArgs Properties
enhancement): abbr
elementClickEvent, oArgs.event (HTMLEvent) children
<div id="myContainer"><div> elementDblclickEvent, oArgs.target (el)
className
elementMousedownEvent,
Script: elementMouseoutEvent, An element is a DOM element, such as button, cell, row, theadCell, editor
elementMouseoverEvent theadLabel, etc. formatter
var myColumnDefs = [{key:"col1", label:"Col 1"}, unitHighlightEvent, oArgs.el (el) hidden
{key:"col2", label:"Col 2"}, ...]; unitSelectEvent, oArgs.record (YAHOO.widget.Record) key
var myDS = new YAHOO.util.DataSource([...]); unitUnhighlightEvent, label
When unit is a cell:
unitUnselectEvent, maxAutoWidth
var myDataTable = new YAHOO.widget.DataTable( cellFormatEvent
oArgs.key (string)
"myContainer", myColumnDefs, myDS); minWidth
A unit is a cell, row, or column.
columnSortEvent oArgs.column (YAHOO.widget.Column) resizeable
oArgs.dir (string) YAHOO.widget.DataTable.CLASS_ASC || selected
Constructor: YAHOO.widget.DataTable YAHOO.widget.DataTable.CLASS_DESC sortable
editorRevertEvent, oArgs.editor (object), oArgs.newData (object), sortOptions.defaultDir
YAHOO.widget.DataTable(str|HTMLElement el, array editorSaveEvent oArgs.oldData (object) sortOptions.sortFunction
column defs, obj DataSource[, obj config]); initEvent, renderEvent n/a width
rowAddEvent oArgs.record (YAHOO.widget.Record)
Arguments: rowDeleteEvent oArgs.oldData (object) YAHOO.widget.ScrollingData
(1) el: HTML ID or HTMLElement for a DataTable container. May be
empty or already contain <table> markup.
oArgs.recordIndex (number) Table Key Attributes
oArgs.trElIndex (number)
(2) column defs: An array of object literals defines Columns. rowUpdateEvent oArgs.record (YAHOO.widget.Record) COLOR_COLUMNFILLER
(3) DataSource: DataSource instance. oArgs.oldData (object) height
(4) configuration object: An optional object literal defines property All DataTable events are Custom Events (see Event Utility docs); subscribe to these events width
values of a DataTable instance. using “subscribe”: (e.g. myDataTable.subscribe("rowSelectEvent", fn); ).
YAHOO.widget.BaseCellEdito
Key DataTable Attributes r Subclasses
Constructor: YAHOO.widget.ScrollingDataTable
Option (type) Default Description CheckboxCellEditor
YAHOO.widget.ScrollingDataTable(str|HTMLElement caption (s) null String values for caption element and summary DateCellEditor
el, array column defs, obj DataSource[, obj summary (s) null attribute.
DropdownCellEditor
draggableColumns (b) false Enables Drag & Drop Column reordering.
config]); RadioCellEditor
initialLoad (b|o) true Enables or customizes data load at instantiation.
initialRequest (mixed) null Request value to send to DataSource at
TextareaCellEditor
Arguments: TextboxCellEditor
instantiation for data to populate the table, if
(1) el: HTML ID or HTMLElement for a DataTable container. May be initialLoad is set to true. Note: Refer to online documentation for a
empty or already contain <table> markup. paginator (o) null Instance of YAHOO.widget.Paginator. complete API reference.
(2) column defs: An array of object literals defines Columns. renderLoopSize 0 Number of rows to render into the DOM each
(3) DataSource: DataSource instance. timeout loop.
(4) configuration object: An optional object literal defines property scrollable (b) false Enables scrolling. Dependencies
values of a DataTable instance, including width and height of width (s)/height (s) null
scrollable area. selectionMode (s) "standard" Configures row or cell selection. DataTable requires the
sortedBy (o) null Displays sorted Column UI. YAHOO Global Object, Event
Utility, Dom Collection,
Cell Editing Abstract Methods Element Utility, and
DataSource Utility.
var myCE = new YAHOO.widget.TextboxCellEditor; Method Description
var myColumnDefs = [{key:"col1}, {key:"col2", doBeforeLoadData Overridable method gives implementers a hook to access data
before it gets added to RecordSet and rendered to the TBODY.
editor: myCE];
...
myDT.subscribe("cellClickEvent",
doBeforeShowCellEditor Overridable abstract method to customize CellEditor before
myDT.onEventShowCellEditor) showing.
doBeforeSortColumn Overridable method gives implementers a hook to show
loading message before sorting Column.
YUI Library: Dialog & SimpleDialog 2009-2-6 v2.7
Simple Use Case: YAHOO.widget.Dialog Key Interesting Moments in Dialog & SimpleDialog YAHOO.widget.Dialog &
See online docs for a complete list of Custom Events associated with Container controls. SimpleDialog: Key
Markup (optional, using HTML form in standard module format): Event Arguments Properties
<div id="myDialog"> beforeSubmitEvent None. body (el)
<div class="bd"> cancelEvent None. form (el)
<form name="dlgForm" method="POST" action=" submitEvent None. callback (o) Connection
post.php"> All events above are YUI Custom Events (see Event Utility docs); subscribe to these Manager callback object for
<label for="firstname">First Name:</label> events using their subscribe method: myDlg.hideEvent.subscribe(fnMyHandler);. async transactions.
<input type="text" name="firstname" /> element (el) containing
Dialog/SimpleDialog Configuration Options
header, body & footer
</form></div>
</div> footer (el)
See online docs for complete list of Container options; see Simple Use Case (top left) for config. syntax.
header (el)
Script: Option (type) Default Description id (s) of the element
text null Sets body text of SimpleDialog
//create the dialog:
(SimpleDialog only). YAHOO.widget.Dialog &
var myDialog = new YAHOO.widget.Dialog("myDialog");
icon “none” Sets url for graphical icon. Six icons SimpleDialog: Methods
//set dialog to use form post on submit action:
myDialog.cfg.queueProperty(“postmethod”, “form”); are provided: ICON_BLOCK,
ICON_WARN, ICON_HELP, appendToBody(el
//set up button handler:
ICON_INFO, ICON_ALARM, and element)
var handleSubmit = function() {
ICON_TIP. (SimpleDialog only.) appendToFooter(el
this.submit(); }; //default submit action
//set up button, link to handler postmethod (s) varies Designates handling of form data; see element)
var myButtons = [ { text:"Submit", box at bottom left. Default is “none” for appendToHeader(el
handler:handleSubmit, isDefault:true } ]); SimpleDialog and “async” for Dialog. element)
//put buttons in configuration queue for processing buttons (a) null Array of button objects. Button objects cancel() Executes cancel then
hide().
myDialog.cfg.queueProperty("buttons", myButtons); contain three members: text label for
getData() Returns obect of
mDialog.render(); //render dialog to page button, handler function to process name/value pairs representing
myDialog.show(); //make dialog visible button click, and isDefault boolean form data.
Solutions
Usage: YAHOO.util.Get.css()
Set up a transaction making use of configuration options; then make use
YAHOO.util.Get.css(str or arr url[s][, obj of the data passed to the callback handler:
options]) var successHandler = function(o) {
//o contains all of the fields described in the callback args table
Arguments: o.purge(); //removes the script node immediately after executing;
(1) URL[s]: A string or array of strings containing the URL[s] to YAHOO.log(o.data); //the data passed in configobject
be inserted in the document via link nodes. }
(2) options: An object containing any configuration options you’d var objTransaction = YAHOO.util.Get.script("http://json.org/json.js",
like to specify for this transaction. See the Configuration { onSuccess: successHandler,
scope: this, //successHandler will run in the scope of “this”
Options table for the full list of options. data: {field1: value1, field2: value2}} //you can pass data in
Note: Returns the same Transaction Object as script(); see above. //any format here
);
YUI Library: ImageCropper Control [beta] 2009-2-6 v2.7
Simple Use Case: YAHOO.widget.ImageCropper ImageCropper Events YAHOO.widget.ImageCropper:
See online docs for complete list of Resize events. Methods
Markup: Event Fires...
<img src="yui.jpg" id="crop1"> getActiveHandleEl() Get the HTML
dragEvent Fires when the DragDrop dragEvent is fired. reference for the currently active resize
Script: startResizeEvent Fires when a resize action is started. handle.
crop = new YAHOO.widget.ImageCropper('crop1'); resizeEvent Fires on event element resize getCropCoords() Get the coordinates
needed to crop the image
Using the above code will get you a rich control that looks moveEvent Fires on every element move. Inside these methods:
_handleKeyPress, _handleDragEvent,
getCropperById() Get an
something like this: ImageCropper object by the HTML id of
_handleResizeEvent the image associated with the
ImageCropper object.
All ImageCropper events are Custom Events (see Element docs); subscribe to these events
using their subscribe method: crop.on(‘resize',fnMyHandler);. getEl() Get the HTML reference for the
image element.
getMaskEl() Get the HTML reference for
Key ImageCropper Configuration Options the mask element.
See online docs for complete list of ImageCropper configuration options. getResizeEl() Get the HTML reference
for the resize element.
Option Default Description
initHeight 1/4 of the Set the initlal height of the crop area. getResizeMaskEl() Get the HTML
reference for the resizable object's mask
image height element.
initWidth 1/4 of image Set the initla width of the crop area. getResizeObject() Get the Resize
width Utility object.
initialXY [10,10] Array of the XY position that we need to set the getWrapEl() Get the HTML reference for
crop element to when we build it. the wrap element.
keyTick 1 The pixel tick for the arrow keys. destroy() Destroys the ImageCropper
object and all of its elements & listeners.
ratio false Constrain the resize to a ratio of the current
size.
status True Show the Resize Utility status.
Most of ImageCropper’s options can be set in the constructor's second argument (eg,
{ratio: true}) or at runtime via set (eg, crop.set("ratio", true);).
YAHOO.widget.
Key MenuItem Configuration Options
See online docs for complete list of MenuItem options. MenuItem: Methods
Option (type) Default Description focus()
checked (b) false Renders the item with a checkmark. blur()
disabled (b) false If set to true the MenuItem will be
dimmed and will not respond to user input
or fire events. Dependencies
selected (b) false If set to true the MenuItem will be
highlighted. Menu requires the
submenu (o) null Appends a menu to the MenuItem. Container Core
target (s) null Value for the "target" attribute of the package, the YAHOO
item’s anchor element. Object, Event, and
text (s) null Text label for the item.
Dom.
url (s) "#" URL for the anchor's "href" attr.
MenuItem options can be set in the constructor's second argument (eg, {disabled: true})
or at runtime via setProperty (eg, oMenuItem.cfg.setProperty("disabled", true);).
YUI Library: Panel 2009-2-6 v2.7
Simple Use Case: YAHOO.widget.Panel Key Interesting Moments in Panel YAHOO.widget.Panel:
See online docs for a complete list of Panel’s Custom Events. Properties
Markup (optional, using standard module format): Event Arguments
<div id="myPanel"> body (el)
<div class="hd">Header content.</div> beforeRenderEvent None. element (el) containing
<div class="bd">Body content.</div> renderEvent None. header, body & footer
'bl', 'br', 'tl', 'tr'. Can use a shortcut of All. Note: 8 way
resizing should be done on an element that is Dependencies
absolutely positioned.
Constructor: YAHOO.util.Resize ratio false Constrain the resize to a ratio of the current size. The Resize Utility requires
draggable false A convenience method to make the element draggable. Yahoo, Dom, Element,
YAHOO.util.Resize(str | el ref container[, obj Event, Drag and Drop and
Most of Resize options can be set in the constructor's second argument (eg, Animation (optional).
config])
{animate: true}) or at runtime via set (eg, resize.set("animate", true);).
Arguments:
(1) Element: The element to make resizable. Resize Handles
(2) Configuration object: When instantiating Resize, you can
pass all configurations in as an object argument or configure The Resize Utility supports the following handle positions: Top, Bottom,
the instance after instantiation. See Configuration Options Left, Right, Top Right, Top Left, Bottom Right, Bottom Left. The default
section for common configuration object members. handle positions are: Right, Bottom, and Bottom Right.
The default look of the handles is to take up all available space around
Solutions: Customizing the Proxy Element the element to be resized. There are a few configuration options built in
that will alter this look:
The following code demonstrates customization of the proxy
element. • hiddenHandles - Handles are always transparent, the user gets
feedback from the cursor change.
//instantiate Resize:
var myResize = new YAHOO.util.Resize('resizeMe', { • hover - Handles are hidden by default until the user hovers over
proxy: true them, then they appear.
}); • knobHandles - Used for the classic 8-way resize.
//customize proxy during resize via innerHTML: Take a look at the Resize Utility's examples for demos of all of these
myResize.on('startResize', function() { options.
myResize.getProxyEl().innerHTML = 'I am the proxy';
Note: To get the best effect out of using all 8 resize handles, it is
YAHOO.util.Dom.setStyle(myResize.getProxyEl(),
'opacity', ',5'); recommended that the element be absolutely positioned (and if possible
}); be a direct child of the body).
YUI Library: Rich Text Editor 2009-2-6 v2.7
Simple Use Case: YAHOO.widget.Editor Interesting Moments in Rich Text Editor & Toolbar YAHOO.widget.Editor:
See online docs for complete list of Rich Text Editor and Toolbar events. Methods
Markup: Event Fires...
<body class="yui-skin-sam"> render() Causes the toolbar and the
editorContentLoaded Fires after the editor iframe’s document fully loads. editor to render and replace the textarea.
<textarea id="msgpost">Preloaded HTML goes here. editorMouseUp, Fires in response to the corresponding Dom event.
setEditorHTML(string html)
editorMouseDown,
</textarea> editorDoubleClick, Loads HTML into the editor’s body.
</body> editorKeyUp, getEditorHTML() Returns the
editorKeyDown unprocessed HTML from the editor.
Script: beforeExecCommand, Fires at the beginning/end of the execCommand process.
saveHTML() Cleans the HTML with
afterExecCommand Reference YAHOO.util.Element.html#addListener for more details.
var oEditor = new YAHOO.widget.Editor('msgpost', beforeOpenWindow, Fires before/after an editor window is opened.
the cleanHTML method and places the string
{ afterOpenWindow into the textarea.
height: '300px', closeWindow Fires after an editor window is closed. cleanHTML(string html)
toolbarExpanded, Fires when toolbar is expanded/collapsed via the collapse button. Processes the HTML with a few regexes to
width: '500px' toolbarCollapsed clean it up and stabilize the output.
}); buttonClick Fires when a toolbar button receives a click event. clearEditorDoc() Clears the editor
oEditor.render(); All Editor events are Custom Events (see Element docs); subscribe to these events using their doc.
subscribe method: oEditor.on(‘afterNodeChange’,fnMyHandler);. destroy() Destroys the editor along
Creates an Editor instance with default configurations. with all of its elements and objects.
toString() Returns a string
Key Rich Text Editor Configuration Options representing the Editor.
See online docs for complete list of Rich Text Editor configuration options. nodeChange() Handles toolbar
Option (type) Default Description setup, getting the Dom path, and fixing
height, width best guessed size of The height/width of the editor iframe container not nodes.
textarea including the toolbar. execCommand(str command[,
animate false Indicates whether or not the editor should animate
movements.
str arg]) Levels the differences in the
support by various browsers of
disabled false Toggle for the editor’s disabled state. When disabled,
execCommand actions.
design mode is off and a mask is placed over the
iframe so no interaction can take place.
dompath false Toggles the display of the current Dom path below the YAHOO.widget.Toolbar:
editor.
toolbar See editor.js.html The default toolbar config.
Methods
handleSubmit false When true, the editor will attempt to attach a submit
listener to the parent form that would trigger the editor’s addButton(obj config) Add a new
save handler and place the new content back into the button to the toolbar.
textarea before the form is submitted. addButtonGroup(obj config)
Adds a new button group to the Toolbar.
Editor options can be set in the constructor's second argument (eg,
{height: '300px'}) or at runtime via set (eg, oEditor.set("height", "300px");). addButtonToGroup(obj
config) Adds a new button group to a
Constructor: YAHOO.widget.Editor Constructor: YAHOO.widget.SimpleEditor
toolbar group.
addSeparator() Adds a new button
YAHOO.widget.Editor(str | el ref container[, obj separator to the toolbar.
YAHOO.widget.SimpleEditor(str | el ref container[, obj getButtonByValue(str | obj
config])
config]) command) Gets a button instance or a
Arguments: menuitem instance from the toolbar by its
Creates a SimpleEditor instance with default configurations. SimpleEditor value.
(1) Container element: <textarea> element or element id for the
is a lighter version of the Editor Control. disableButton(str | number |
<textarea> that will be transformed into a Rich Text Editor.
(2) Configuration object: When instantiating an Editor, you can obj button) Disables a button in the
toolbar.
pass all configurations in as an object argument or configure enableButton(str | number |
the instance after instantiation. See Configuration Options obj button) Enables a button in the
section for common configuration object members. toolbar.
selectButton(str | number |
Dependencies obj button) Selects a button in the
toolbar.
Editor: Yahoo, Dom, Event, Element, ContainerCore; Animation, Menu deselectButton(str | number
and Button are optional. SimpleEditor: YAHOO, Dom, Event, and | obj button) Deselects a button in the
toolbar.
Element; Animation and ContainerCore are optional.
YUI Library: Selector Utility 2009-2-6 v2.7
Usage: query() Pseudo-classes YAHOO.util.Selector Methods
The Selector Utility supports the use of the pseudo-classes listed here; for more info on these, query(string selector[, node | string
Use query to select one or more DOM elements based on a see the W3C Selectors working draft (http://www.w3.org/TR/css3-selectors/#pseudo-classes). startingNode, bool firstOnly]) the
simple selector string. The query method is used to return all startingNode can be passed in as a string
Pseudo-class Description element ID or as an element reference
nodes that match your criteria unless the firstOnly arg is true. :root The root of the document; in HTML 4.x, this is the HTML element. and defaults to the document element;
:nth- Starting from the bth child, match every ath element. returns an array of matching nodes
var matchingNodes = YAHOO.util.Selector.query child(an+b) filter(arr | nodeList nodes, string
(“ul li a”, “itemList”); selector) returns any nodes that match
:nth-last- An element that has an + b siblings after it. the selector
Note: Will return all anchor elements within list-items of unordered lists who are descendants of child(an+b) test(str | elRef node, string selector)
the element whose id attribute is “itemList”. :nth-of- An element that has an + b siblings before it that share the same returns boolean indicating whether the
type(an+b) element name. node matches the selector criteria
:nth-last-of- An element that has an + b siblings after it that share the same
Usage: YAHOO.util.Selector.query() type(an+b) element name.
Combinators
YAHOO.util.Selector.query(string selector[, node :first-child Same as :nth-child(1) — the first child of a given element.
The Selector Utility supports the
:last-child Same as :nth-last-child(1) — the last child of a given element.
| string startingNode, bool firstOnly]) following four combinators:
:first-of-type Same as :nth-of-type(1) — the first child of a given element with a Descendant
given element name. “”
Arguments: Combinator: “A B”
(1) selector: A string representing the CSS selector you want to :last-of-type Same as :nth-last-of-type(1) — the last child of a given type of the represents an element
specified element. B that has A as an
target.
:only-child An element who is the only child of its parent node. ancestor.
(2) startingNode: The node at which to begin the search :only-of-type An element whose element name is not shared by any sibling nodes.
> Child Combinator: “A >
(defaults to document). Be as specific as possible in choosing :empty An element that has no children. B” represents an
your startingNode to maximize performance. :not() The negation pseudo-class; takes a simple selector as an argument, element B whose
(3) firstOnly: Whether or not to return only the first match. representing an element not represented by the argument. parent node is A.
:contains() An element whose textual contents contain the substring provided in + Direct Adjacent
Returns: the argument. Combinator: “A + B”
(1) Matching Node(s): An array of nodes that match your :checked A radio button or checkbox that is in a checked state. represents an element
selector criteria. If firstOnly is true, this returns a single Notes regarding (an+b) notation: B immediately following
Starting from the bth child, match every ath element. For example, “nth-child(2n+1)” starts from the first a sibling element A.
node or null if no match. element and returns every other element. The “odd” and “even” keywords are supported, so “2n+1” is
equivalent to “odd”. “1n+2” and “n+2” are equivalent. “nth-child(0n+3)” is equivalent to “nth-child(3)”. Zero ~ Indirect Adjacent
value means no repeat matching, thus only the first bth element is matched. “3n+0” is equivalent to “3n”. Combinator: “A ~ B”
Usage: YAHOO.util.Selector.filter() represents an element
B following (not
YAHOO.util.Selector.filter(arr | nodeset nodes, Attribute Operators necessarily
string selector) att=val equality att^=val value starts with val immediately following)
att!=val inequality att$=val value ends with val a sibling element A.
Arguments: att~=val value matches one of att*=val value contains at least one
(1) nodes: A nodeList or an array of nodes from which you want space-delimited words in occurrence of val
to select specific nodes that match your criteria. val Dependencies
(2) selector: A CSS selector against which you want to test and att|=val value starts with val or val- att test for the existence of the
attribute The Selector Utility requires
filter the nodes. only the YAHOO Global
Solutions Object.
Usage: YAHOO.util.Selector.test()
Selector.query(“#nav ul:first-of-type > li:not(.selected)”); //
YAHOO.util.Selector.test(str | elRef node, Starting from the first “ul” inside of “nav” , return all “li”
elements that do not have the “selected” class.
string selector)
Selector.query(“ul:first-of-type > li.selected”, “nav”, true); //
Arguments: Starting from the first “ul” inside of “nav” , return the first
(1) node: A node to test “li” element that has the “selected” class.
(2) selector: A CSS selector against which you want to test ther
Dom.addClass(Selector.query(“#data tr:nth-child(odd)”), “odd” ) //
the node. add the class “odd” to all odd rows within the “data” element.
Note: returns true if the node matches the selector, otherwise false.
YUI Library: S lider 2009-2-13 v2.7
Simple Use Case Interesting Moments in Slider see online docs for complete list YAHOO.widget.Slider:
Factory Methods
Markup: Event Fires... Arguments
getHorizSlider()
<div id="sliderbg"> slideStart ...at the beginning of a none
getVertSlider()
<div id="sliderthumb"><img src="thumbimg"></div> user-initiated change in
</div> getSliderRegion()
the thumb position.
Each method returns a Slider object.
Script: slideEnd ... at the end of a user- none See Constructor section for args list.
var slider = initiated change in the
YAHOO.widget.Slider.getHorizSlider("sliderbg", thumb position. YAHOO.widget.Slider:
"sliderthumb", 0, 200);
change ...each time the thumb int or {x: int, y:int} Properties
Creates a horizontal Slider within the sliderthumb div that can move position changes during a offset from the starting position,
one offset per slider dimension animate (b)
0 pixels left and 200 pixels to the right. user-initiated move. animationDuration (n)
Slider events are Custom Events; subscribe to them by name using the following default 0.2, roughly in seconds
Constructor: YAHOO.widget.Slider syntax: mySlider.subscribe("change", fn);. keyIncrement (n) number of
pixels to move slider on arrow
keypress
YAHOO.widget.Slider.getHorizSlider(str bgid, str Slider Design Considerations
thumbid, int lft/up, int rt/dwn[, int tick]);
YAHOO.widget.Slider:
Arguments for Horizontal and Vertical Sliders: Methods
(1) Background element ID: HTML ID for the slider’s background.
(2) Thumb element ID: HTML ID for the thumb element. getValue()
(3) Left/Up: The number of pixels the thumb can move left or up. getXValue()
(4) Right/Down: The number of pixels the thumb can move right or getYValue()
down. lock()
(5) Tick interval: Number of pixels between each tick mark. setRegionValue(int
newXOffset, int
Region Sliders take four args for range: left, right, up, down. newYOffset, b
A Slider is an implementation of a "finite range control." The range defined skipAnimation)
Solutions by the Slider is incremented in pixels. The maximum range of a slider is setValue(int newOffset, b
the pixel-width of the Slider's background minus the width of the skipAnimation)
Create a vertical Slider with a range of 300 pixels, ticks at 10 px Slider Thumb.
unlock()
intervals, and an initial value of 160:
var slider = Region Sliders: CSS Notes:
YAHOO.widget.Slider.getVertSlider("sliderbg",
A two-dimensional Slider is referred to • Slider background should
"sliderthumb", 0, 300, 10);
as a Region Slider. Region Sliders be position:relative;
slider.setValue(160, true); //set to 160, skip anim
report two values onChange (x offset, y • Slider thumb should be
Create a 300x400 pixel region Slider and set the initial thumb position offset) and have their own method for position:absolute;
to 263 on the x-axis and 314 on the y-axis: setting value in JavaScript: • Slider thumb image should
setRegionValue takes x offset and y not be a background image
var slider = • Alternately use Slider’s skin
offset as arguments, followed by the
YAHOO.widget.Slider.getSliderRegion("sliderbg", CSS file for default
boolean flag for skipping animation.
"sliderthumb", 0, 300, 0, 400); appearance. (see online
Design considerations regarding range
slider.setRegionValue(263, 314, true); docs)
and thumb width apply in both vertical
Assuming an instance of a horizontal Slider in variable mySlider, and horizontal dimensions.
write a handler for its onSlideEnd event:
mySlider.subscribe("slideEnd", function() { Dependencies
alert(this.getValue()); //alerts offset from start
}); Slider requires the YAHOO object, Event, Drag & Drop, Dom, and
(optionally) Animation.
YUI Library: Slider with Dual Thumbs 2009-2-6 v2.7
Simple Use Case Interesting Moments in DualSlider see docs for full list YAHOO.widget.Slider: Factory
Methods
Markup: Event Fires... Arguments
getHorizDualSlider()
<div id="sliderbg"> slideStart ...at the beginning of a Slider instance
getVertDualSlider()
<div id="minthumb"><img src="thumbimg"></div> user-initiated change in
<div id="maxthumb"><img src="thumbimg"></div> either thumb position. Slider instance housing the Each method returns a DualSlider object. See
active thumb Constructor section for args list.
</div>
slideEnd ... at the end of a user- Slider instance
Script: YAHOO.widget.DualSlider:
initiated change in either
var slider = Slider instance housing the Properties
YAHOO.widget.Slider.getHorizDualSlider( thumb position. active thumb
“sliderbg","minthumb",“maxthumb”, 200); change ...each time either of the DualSlider minVal (n) (read only)
thumbs’ positions instance maxVal (n) (read only)
Creates two thumbs (minthumb and maxthumb) that can move within
change during a user- isHoriz (b) (read only)
a horizontal 200 pixel range on a slide background (slidebg).
minSlider (Slider) (read only)
initiated move.
maxSlider (Slider) (read only)
Constructor: YAHOO.widget.DualSlider DualSlider events are Custom Events; subscribe to them by name using the
following syntax: mySlider.subscribe("change", fn);.
minRange (n) (read / write)
YAHOO.widget.Slider.getHorizDualSlider(str bgid, minimum number of pixels the inner edges
str minthumbid, str maxthumbid, int range[, int DualSlider Design Considerations of the thumbs can be apart
tick[,array initVals]]]);
DualSlider is an implementation of a YAHOO.widget.DualSlider:
Arguments for Horizontal and Vertical DualSliders: "finite range control." The range
(1) Background element ID: HTML ID for the slider’s background. Methods
defined by the DualSlider thumbs is
(2) Min Thumb element ID: HTML ID for the thumb element expressed in pixels. setMinValue(int)
representing the lower value. setMaxValue(int)
(3) Max Thumb element ID: HTML ID for the thumb element The maximum range of a slider is setValues(int newMinOffset,
representing the upper value. the pixel-width of the DualSlider's int newMaxOffset,
(4) Range: The maximum pixel offset for the Max Thumb. background minus half the width b skipAnimation)
(5) Tick interval: Number of pixels between each tick mark. of the Min Thumb minus half the
(7) Initial Values: Array containing the desired Min Thumb and Max width of the Max Thumb. YAHOO.widget.DualSlider:
Thumb pixel offsets to assign during instantiation.
Values for each thumb are
Dependencies
calculated according to their center
Solutions point. To quantify the space
DualSlider requires the YAHOO
object, Dom, Event, Drag & Drop,
Create a vertical DualSlider with a 300 pixel range, ticks at 10 px between the thumbs, use this and (optionally) Animation.
formula:
intervals, and initial values of 160 and 220:
var slider =
CSS Notes:
innerDiff = maxVal - minVal -
YAHOO.widget.Slider.getVertDualSlider("sliderbg" (maxThumbWidth/2) - • DualSlider background should
, "minthumb", “maxthumb”, 300, 10, [160,220] ); be position:relative;
(minThumbWidth/2)
• Slider thumbs should be
Assuming an instance of a DualSlider in variable mySlider, write a position:absolute;
handler for its change event: • Slider thumb image should not
be a background image
mySlider.subscribe("change", function() {
alert(“MIN: “+this.minVal+” MAX: “+this.maxVal);
});
YUI Library: TabView 2009-2-6 v2.7
Simple Use Case: YAHOO.widget.TabView Key Interesting Moments in TabView YAHOO.widget.TabView:
See online docs for a complete list of TabView's Events; see Solutions for how to access Event Fields. Properties
Markup (optional, using standard module format): Event: Event Fields: CLASSNAME
<div id="mytabs" class=”yui-navset”> TAB_PARENT_CLASSNAME
available type (s), target (el)
<ul class="yui-nav"> CONTENT_PARENT_CLASSNAME
<li><a href=” … ”>tab one</a></li> beforeActiveTabChange type (s), prevValue (Tab), newValue (Tab)
<li><a href=” … ”>tab two</a></li> contentReady type (s), target (el) YAHOO.widget.TabView:
</ul> activeTabChange type (s), prevValue (Tab), newValue (Tab)
All TabView events are Custom Events (see Event Utility docs); subscribe to these events Methods
<div class=”yui-content”>
using “addListener”: (e.g. myTabs.addListener(‘activeTabChange”, fn); ). addTab(Tab)
<div><p>Tab one content.</p></div>
<div><p>Tab two content.</p></div> removeTab(Tab)
</div> Key Interesting Moments in Tab getTab(i)
</div> See online docs for a complete list of Tab's Events; see Solutions for how to access Event Fields. getTabIndex(Tab)
Event: Event Fields: contentTransition()
Script: beforeContentChange type (s), prevValue (s), newValue (s) set(option, value)
var myTabs = new YAHOO.widget.TabView("mytabs"); beforeActiveChange type (s), prevValue (Tab), newValue (Tab) get(option)
Creates a TabView instance using existing markup. contentChange type (s), prevValue (s), newValue (s)
activeChange type (s), prevValue (Tab), newValue (Tab) YAHOO.widget.
Constructor: YAHOO.widget.TabView
All TabView events are Custom Events (see Event Utility docs); subscribe to these events Tab: Properties
using addListener (e.g. myTabs.addListener(‘activeChange”, fn); ).
LABEL_TAGNAME
YAHOO.widget.TabView(str|HTMLElement|obj el[,
obj config]);
Key TabView Configuration Options ACTIVE_CLASSNAME
See online docs for complete list of TabView options. DISABLED_CLASSNAME
Arguments: LOADING_CLASSNAME
Option (type) Default Description
(1) el: HTML ID or HTMLElement of existing markup to use when activeTab null The currently active Tab.
building tabView. If neither, this is treated as the (Tab) YAHOO.widget.
Configuration object. orientation “top” The orientation of the Tabs relative to the Tab: Methods
(2) Configuration Object: JS object defining configuration TabView. (“top”, “right”, “bottom”, “left”)
set(option, value)
properties for the TabView instance. See Configuration get(option)
element null HTMLElement bound to TabView
section for full list.
TabView options can be set in the constructor's second argument (eg, {activeTab:
tabInstance}) or at runtime via set (eg, myTabs.set("activeTab", tabInstance);).
Dependencies
Solutions Key Tab Configuration Options
See online docs for complete list of Tab configuration options.
TabView requires the
Listen for a TabView Event and make use of the Event's fields. Option (type) Default Description YAHOO object, Event,
Dom, and Element.
var tabView = new YAHOO.widget.TabView('demo'); active (b) false Whether or not the Tab is active.
var handleActiveTabChange = function(e) { disabled (b) false Whether or not the Tab is disabled.
alert(e.newValue); label (s) null The text (or innerHTML) to use as the Tab’s
}; label.
tabView.addListener(‘activeTabChange’, content (s) null The HTML displayed when the Tab is active.
handleActiveTabChange); labelEl (el) null The HTMLElement containing the label.
Add a new Tab with with dynamic source to an existing contentEl (el) null The HTMLElement containing the
TabView instance: contentEl.
tabView.addTab(new YAHOO.widget.Tab({label: ‘My dataSrc (s) null Url to use for retrieving content.
Label’, dataSrc: ‘mySource.html’, cacheData (b) false Whether or not data retrieved from dataSrc
cacheData:true})); should be cached or reloaded each time the
Tab is activated.
Remove an existing tab from a TabView:
Element (el) null HTMLElement bound to Tab
tabView.removeTab(tabView.getTab(1)); Tab options can be set in the constructor's second argument (eg, {disabled: true}) or at
runtime via set (eg, myTab.set("disabled", true);).
YUI Library: TreeView 2009-2-6 v2.7
Simple Use Case Interesting Moments in TreeView see docs for complete list YAHOO.widget.
TreeView: Properties
var tree = new YAHOO.widget.TreeView("treeDiv1"); Event Fires... Arguments
id (str)
var root = tree.getRoot(); expand ...before a node expands; Node obj expanding
var tmpNode = new YAHOO.widget.TextNode("mylabel", return false to cancel. node
collapse ...before a node collapses; Node obj collapsing YAHOO.widget.
root);
tree.render(); return false to cancel node TreeView: Methods
clickEvent ...when node is clicked Node clicked and event collapseAll()
Places a TreeView Control in the HTML element whose ID attribute is dblClickEvent ... when node is double Node clicked and event render()
"treediv1"; adds one node to the top level of the tree and renders. clicked expandAll()
enterKeyPressed ... when Enter key is pressed Node obj with the focus getNodesByProperty()
when a node has the focus getRoot()
Constructor: YAHOO.widget.TreeView popNode(node) returns detached
TreeView events are Custom Events; subscribe to them by name using the following node, which can then be reinserted