YUI recommends YUI3.
YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.
This documentation is no longer maintained.
Use the show/hide buttons below to show and hide two simple panels. The first panel is created based on markup on the page and its draggable
configuration is set to true
; it can be dragged around the screen.
The Panel Control is an extension of Overlay that is meant to behave similarly to an OS window. Unlike true browser popup windows, Panel Control instances 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 the default look and feel characteristics that you see on this page.
In this tutorial, we will build two Panels. One of them will be based on existing markup; the other will be created dynamically using script. We'll pass configuration properties via the constructor to specify any non-default settings we want to use in our Panel instances.
The markup for panel1
is in standard module format, as is required by the Module and Overlay classes on which Panel is built. We also provide buttons to allow for easy showing and hiding of both Panels:
Since we're generating panel2
from script, the only markup we add is a placeholder to render the panel to (The id of which, we pass to the panel2.render("container")
call below):
As with the other examples, to avoid adding to the global namespace, we start by creating an example.container
namespace within the YAHOO global object to hold the panel instances:
We then create our Panel instance, and add them to the global namespace:
These Panels introduce a few configuration properties. The constraintoviewport
property, when set to true, will keep the Panel from being positioned outside of the viewport; this defends against the panel being dragged out of the viewport by the user and against the panel being moved outside the viewport by scripted changes to its x/y properties. The draggable
property determines whether the Panel can be dragged (be sure to include the Drag and Drop Utility if you want your panel to be draggable), and the close
property determines whether the close icon should be displayed in the header of the Panel.
Finally, we add some event listeners to the buttons to show and hide the panel:
Note: You are viewing this example in debug mode with logging enabled. This can significantly slow performance.
All YUI 2.x users should review the YUI 2.8.2 security bulletin, which discusses a vulnerability present in YUI 2.4.0-2.8.1.
Copyright © 2013 Yahoo! Inc. All rights reserved.