The Panel control is an extension of Overlay that is meant to behave similarly to an OS window. Unlike true browser popup windows, panels are floating DHTML elements embedded directly within the page context. The Panel control extends the functionality of Overlay, adding support for modality, drag and drop, and close/dismiss buttons. Panel includes a pre-defined stylesheet to support default look and feel characteristics.
To use Panel, include the following code in your page:
Instead of copying and pasting the filepaths above, try letting the YUI dependency Configurator determine the optimal file list for your desired components; the Configurator uses YUI Loader write out the full HTML for including the precise files you need for your implementation.
Note: If you wish to include this component via the YUI Loader, its module name is container. (Click here for the full list of module names for YUI Loader.)
Where these files come from: The files included using the text above will be served from Yahoo! servers; see "Serving YUI Files from Yahoo!" for important information about this service. JavaScript files are minified, meaning that comments and white space have been removed to make them more efficient to download. To use the full, commented versions or the -debug versions of YUI JavaScript files, please download the library distribution and host the files on your own server.
Order matters: As is the case generally with JavaScript and CSS, order matters; these files should be included in the order specified above. If you include files in the wrong order, errors may result.
Using "CSS skins": One of the files listed above contains a CSS "skin" for the Panel Control. For this skin CSS to work correctly, you will need to apply the CSS class "yui-skin-sam" to an element that is a parent of the element in which the component lives. You can usually accomplish this simply by putting the class on the <body> tag:
<body class="yui-skin-sam">
For more information on skinning YUI components and making use of default skins, see our Understanding YUI Skins article here on the website.
This section describes common tasks for creating and using Panel. It contains these sections:
Panel inherits its constructor and configuration, as well as several other important methods, from Overlay. See Overlay for more information on how to utilize Panel's inherited features.
HTML markup for Panel uses the same modular format underlying Module. Placing a panel's markup in the page, rather than adding Panel content via script once the Panel instance is created, allows you to use Progressive Enhancement — showing the full content and functionality of your site to users who may have older browsers or who have JavaScript disabled while still providing a richer interaction to modern, standards-compatible browsers. In most cases, you won't place a Panel's content on the page prior to creating the panel; setting content dynamically is the most common use case. However, where it's possible and useful to do so, you may instantiate a Panel based on modular content that follows the following pattern (inherited from Module):
Panel is easy to use and can generate extremely powerful interactions with simple configuration options and CSS styling. In its simplest case, a Panel's constructor looks like this:
More often, you'll want to configure some of the properties of Panel by passing in a configuration object as the second argument to your constructor. Configuration options are detailed later in this document; here is an example that implements some very common configurations:
For more information about Panel's many configuration options, see Configuration Properties below. For more ideas about how to use Panel and how to customize its look and feel, see the Examples.
Once initialized, a Panel is rendered in the same way as Module, by invoking the
render() method. As with Module, if the Panel was not created from markup you need to pass to the render
method, the parent element to which the Panel should be added.
Panel has the following configuration properties:
| Name | Type | Default | Description |
|---|---|---|---|
| close | Boolean | null | Whether a "close" icon should be displayed in the header. |
| draggable | Boolean | "true" if the Drag and Drop utility is included, otherwise "false." | Whether to allow the user to drag the Panel using its header. |
| underlay | String | "shadow" | Specifies the type of underlay to display under the Panel. Other options include "none", and "matte", which renders a small white matte under the Panel. |
| modal | Boolean | false | Specifies whether the document should be shielded with a partially transparent mask to require the user to close the Panel before being able to activate any elements in the document.
NOTE: When enabling modality, it is strongly recommended that you render the Panel to
For example, if you render a modal Panel inside a relatively positioned ancestor, which doesn't have a z-index, in IE the mask will render on top of the Panel, whereas in all other browsers it will render correctly underneath the Panel unless you control the z-index of the postioned ancestor in relation to the mask. |
| keylisteners | YAHOO.util.KeyListener / Array | null | A KeyListener or Array of KeyListeners containing key events to enable when the Panel is displayed. |
Panel has the following inherited configuration properties:
| Name | Type | Default | Description |
|---|---|---|---|
| visible | Boolean | true | Sets whether or not the Panel is visible on the page (Panel uses the CSS "visibility" property to control this). |
| effect | Object / Object[] | none | Sets the ContainerEffect (one or many) that should be used when showing and hiding the Panel. |
| monitorresize | Boolean | true | Configures whether or not to create a hidden off-screen element that can be used to monitor for text size changes in the DOM. |
| x | Number | null | Sets the element's "left" style property. |
| y | Number | null | Sets the element's "top" style property. |
| xy | Array | null | Sets the element's "top" and "left" style properties. |
| context | Array | null | Allows the Overlay to be anchored to a context element. The format is: [element, elementCorner, contextCorner], where "element" is an element or element id, and the corner parameters are either "tr" (top right), "tl" (top left), "br" (bottom right), or "bl" (bottom left). |
| fixedcenter | Boolean | false | Specifies whether the Overlay should be automatically centered in the viewport on window scroll and resize. |
| width | String | null | Sets the element's "width" style property. |
| height | String | null | Sets the element's "height" style property. |
| zIndex | Number | null | Sets the element's "z-index" style property. |
| constraintoviewport | Boolean | false | If set to true the Overlay will try to remain inside the confines of the size of viewport. |
| iframe | Boolean | false (true by default for IE 6 and below) | If set to true the Menu will have and iframe behind it to prevent other elements with a higher z-index from poking through. |
The YUI Library and related topics are discussed on the on the ydn-javascript mailing list.
In addition, please visit the YUIBlog for updates and articles about the YUI Library written by the library's developers.
The YUI Library's public bug tracking and feature request repositories are located on the YUI SourceForge project site. Before filing new feature requests or bug reports, please review our reporting guidelines.














Copyright © 2008 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings