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.
1 | // Instantiate a Panel from markup |
2 | YAHOO.example.container.panel1 = new YAHOO.widget.Panel("panel1", { width:"320px", visible:false, constraintoviewport:true } ); |
3 | YAHOO.example.container.panel1.render(); |
4 | |
5 | // Instantiate a Panel from script |
6 | YAHOO.example.container.panel2 = new YAHOO.widget.Panel("panel2", { width:"320px", visible:false, draggable:false, close:false } ); |
7 | YAHOO.example.container.panel2.setHeader("Panel #2 from Script"); |
8 | YAHOO.example.container.panel2.setBody("This is a dynamically generated Panel."); |
9 | YAHOO.example.container.panel2.setFooter("End of Panel #2"); |
10 | YAHOO.example.container.panel2.render("container"); |
view plain | print | ? |
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.
The context
property takes an array of arguments. The first argument in the array is the id of the element to which we want to anchor our Panel instance. In this case, that element is a <div>
with an id of ctx
. The next two arguments specify the positioning of the Panel — tl
and bl
mean, "Anchor my Panel's top left corner to my context element's bottom left corner." (Other possible values include "tr" and "br" for "top right" and "bottom right", respectively.)
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:
1 | <div> |
2 | <button id="show1">Show panel1</button> |
3 | <button id="hide1">Hide panel1</button> |
4 | </div> |
5 | |
6 | <div id="panel1"> |
7 | <div class="hd">Panel #1 from Markup</div> |
8 | <div class="bd">This is a Panel that was marked up in the document.</div> |
9 | <div class="ft">End of Panel #1</div> |
10 | </div> |
11 | |
12 | <div> |
13 | <button id="show2">Show panel2</button> |
14 | <button id="hide2">Hide panel2</button> |
15 | </div> |
view plain | print | ? |
INFO2664ms (+0) 1:11:06 AM:Config
Firing Config event: iframe=false
INFO2664ms (+0) 1:11:06 AM:Config
setProperty: xy=8,489.3125
INFO2664ms (+0) 1:11:06 AM:Config
setProperty: y=489.3125
INFO2664ms (+0) 1:11:06 AM:Config
setProperty: x=8
INFO2664ms (+0) 1:11:06 AM:Config
Firing Config event: iframe=false
INFO2664ms (+0) 1:11:06 AM:Config
setProperty: xy=8,354.3125
INFO2664ms (+0) 1:11:06 AM:Config
setProperty: y=354.3125
INFO2664ms (+6) 1:11:06 AM:Config
setProperty: x=8
INFO2658ms (+0) 1:11:06 AM:Config
setProperty: zindex=0
INFO2658ms (+0) 1:11:06 AM:Config
Firing Config event: zindex=null
INFO2658ms (+0) 1:11:06 AM:Config
Firing Config event: iframe=false
INFO2658ms (+0) 1:11:06 AM:Config
Firing Config event: visible=false
INFO2658ms (+0) 1:11:06 AM:Config
Firing Config event: close=false
INFO2658ms (+0) 1:11:06 AM:Config
Firing Config event: draggable=false
INFO2658ms (+0) 1:11:06 AM:Config
Firing Config event: fixedcenter=false
INFO2658ms (+0) 1:11:06 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, dragonly=false, underlay=shadow, modal=false, width=320px, fixedcenter=false, draggable=false, close=false, visible=false, iframe=false, zindex=null,
INFO2658ms (+0) 1:11:06 AM:Config
queueProperty: iframe=undefined
INFO2658ms (+0) 1:11:06 AM:Config
Firing Config event: width=320px
INFO2658ms (+0) 1:11:06 AM:Config
setProperty: zindex=0
INFO2658ms (+0) 1:11:06 AM:Config
Firing Config event: zindex=null
INFO2658ms (+0) 1:11:06 AM:Config
Firing Config event: modal=false
INFO2658ms (+0) 1:11:06 AM:Config
Firing Config event: underlay=shadow
INFO2658ms (+0) 1:11:06 AM:Config
Firing Config event: dragonly=false
INFO2658ms (+0) 1:11:06 AM:Config
Firing Config event: constraintoviewport=false
INFO2658ms (+0) 1:11:06 AM:Config
Firing Config event: appendtodocumentbody=false
INFO2658ms (+1) 1:11:06 AM:Config
Firing Config event: monitorresize=true
INFO2657ms (+0) 1:11:06 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, dragonly=false, underlay=shadow, modal=false, zindex=null, width=320px, fixedcenter=false, iframe=false, draggable=false, close=false, visible=false,
INFO2657ms (+0) 1:11:06 AM:Config
queueProperty: close=false
INFO2657ms (+0) 1:11:06 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, close=true, dragonly=false, underlay=shadow, modal=false, zindex=null, width=320px, fixedcenter=false, iframe=false, draggable=false, visible=false,
INFO2657ms (+0) 1:11:06 AM:Config
queueProperty: draggable=false
INFO2657ms (+0) 1:11:06 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, close=true, dragonly=false, draggable=true, underlay=shadow, modal=false, zindex=null, width=320px, fixedcenter=false, iframe=false, visible=false,
INFO2657ms (+0) 1:11:06 AM:Config
queueProperty: visible=false
INFO2657ms (+0) 1:11:06 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, constraintoviewport=false, close=true, dragonly=false, draggable=true, underlay=shadow, modal=false, visible=true, zindex=null, width=320px, fixedcenter=false, iframe=false,
INFO2657ms (+0) 1:11:06 AM:Config
queueProperty: width=320px
INFO2657ms (+0) 1:11:06 AM:Config
setProperty: keylisteners=undefined
INFO2657ms (+0) 1:11:06 AM:Config
Added property: keylisteners
INFO2657ms (+0) 1:11:06 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, constraintoviewport=false, iframe=false, close=true, dragonly=false, draggable=true, underlay=shadow, modal=false, visible=true, zindex=null,
INFO2657ms (+0) 1:11:06 AM:Config
queueProperty: modal=false
INFO2657ms (+0) 1:11:06 AM:Config
setProperty: modal=false
INFO2657ms (+0) 1:11:06 AM:Config
Added property: modal
INFO2657ms (+0) 1:11:06 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, constraintoviewport=false, iframe=false, zindex=null, close=true, dragonly=false, draggable=true, underlay=shadow, visible=true,
INFO2657ms (+0) 1:11:06 AM:Config
queueProperty: underlay=shadow
INFO2657ms (+0) 1:11:06 AM:Config
setProperty: underlay=shadow
INFO2657ms (+0) 1:11:06 AM:Config
Added property: underlay
INFO2657ms (+0) 1:11:06 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, constraintoviewport=false, iframe=false, zindex=null, close=true, visible=true, dragonly=false, draggable=true,
INFO2657ms (+0) 1:11:06 AM:Config
queueProperty: dragonly=false
INFO2657ms (+0) 1:11:06 AM:Config
setProperty: dragonly=false
INFO2657ms (+0) 1:11:06 AM:Config
Added property: dragonly
INFO2657ms (+0) 1:11:06 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, constraintoviewport=false, iframe=false, zindex=null, close=true, draggable=true, visible=true,
INFO2657ms (+0) 1:11:06 AM:Config
queueProperty: draggable=true
INFO2657ms (+0) 1:11:06 AM:Config
setProperty: draggable=true
INFO2657ms (+0) 1:11:06 AM:Config
Added property: draggable
INFO2657ms (+0) 1:11:06 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, constraintoviewport=false, iframe=false, zindex=null, close=true, visible=true,
INFO2657ms (+0) 1:11:06 AM:Config
queueProperty: close=true
INFO2657ms (+0) 1:11:06 AM:Config
setProperty: close=true
INFO2657ms (+0) 1:11:06 AM:Config
Added property: close
INFO2657ms (+0) 1:11:06 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, constraintoviewport=false, iframe=false, zindex=null,
INFO2657ms (+0) 1:11:06 AM:Config
queueProperty: iframe=false
INFO2657ms (+0) 1:11:06 AM:Config
setProperty: iframe=false
INFO2657ms (+0) 1:11:06 AM:Config
Added property: iframe
INFO2657ms (+0) 1:11:06 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, zindex=null, constraintoviewport=false,
INFO2657ms (+0) 1:11:06 AM:Config
queueProperty: constraintoviewport=false
INFO2657ms (+0) 1:11:06 AM:Config
setProperty: constraintoviewport=false
INFO2657ms (+0) 1:11:06 AM:Config
Added property: constraintoviewport
INFO2657ms (+0) 1:11:06 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true, zindex=null,
INFO2657ms (+0) 1:11:06 AM:Config
queueProperty: zindex=null
INFO2657ms (+0) 1:11:06 AM:Config
setProperty: zindex=null
INFO2657ms (+0) 1:11:06 AM:Config
Added property: zindex
INFO2657ms (+0) 1:11:06 AM:Config
setProperty: height=undefined
INFO2657ms (+0) 1:11:06 AM:Config
Added property: height
INFO2657ms (+0) 1:11:06 AM:Config
setProperty: width=undefined
INFO2657ms (+0) 1:11:06 AM:Config
Added property: width
INFO2657ms (+0) 1:11:06 AM:Config
Config event queue: monitorresize=true, appendtodocumentbody=false, fixedcenter=false, visible=true,
INFO2657ms (+0) 1:11:06 AM:Config
queueProperty: fixedcenter=false
INFO2657ms (+0) 1:11:06 AM:Config
setProperty: fixedcenter=false
INFO2657ms (+0) 1:11:06 AM:Config
Added property: fixedcenter
INFO2657ms (+0) 1:11:06 AM:Config
setProperty: context=undefined
INFO2657ms (+1) 1:11:06 AM:Config
Added property: context
INFO2656ms (+0) 1:11:06 AM:Config
setProperty: xy=undefined
INFO2656ms (+0) 1:11:06 AM:Config
Added property: xy
INFO2656ms (+0) 1:11:06 AM:Config
setProperty: y=undefined
INFO2656ms (+0) 1:11:06 AM:Config
Added property: y
INFO2656ms (+0) 1:11:06 AM:Config
setProperty: x=undefined
INFO2656ms (+0) 1:11:06 AM:Config
Added property: x
INFO2656ms (+0) 1:11:06 AM:Config
Config event queue: visible=true, monitorresize=true, appendtodocumentbody=false,
INFO2656ms (+0) 1:11:06 AM:Config
queueProperty: appendtodocumentbody=false
INFO2656ms (+0) 1:11:06 AM:Config
setProperty: appendtodocumentbody=false
INFO2656ms (+0) 1:11:06 AM:Config
Added property: appendtodocumentbody
INFO2656ms (+0) 1:11:06 AM:Config
Config event queue: visible=true, monitorresize=true,
INFO2656ms (+0) 1:11:06 AM:Config
queueProperty: monitorresize=true
INFO2656ms (+0) 1:11:06 AM:Config
setProperty: monitorresize=true
INFO2656ms (+0) 1:11:06 AM:Config
Added property: monitorresize
INFO2656ms (+0) 1:11:06 AM:Config
setProperty: effect=undefined
INFO2656ms (+0) 1:11:06 AM:Config
Added property: effect
INFO2656ms (+0) 1:11:06 AM:Config
Config event queue: visible=true,
INFO2656ms (+0) 1:11:06 AM:Config
queueProperty: visible=true
INFO2656ms (+0) 1:11:06 AM:Config
setProperty: visible=true
INFO2656ms (+0) 1:11:06 AM:Config
Added property: visible
INFO2656ms (+0) 1:11:06 AM:Config
setProperty: zindex=0
INFO2656ms (+2656) 1:11:06 AM:Config
Firing Config event: zindex=null
INFO0ms (+0) 1:11:03 AM:global
Logger initialized
Note: You are viewing this example in debug mode with logging enabled. This can significantly slow performance.
Copyright © 2008 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings