153 lines
No EOL
6.7 KiB
HTML
153 lines
No EOL
6.7 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
|
<title>YUI Container - Using OverlayManager (YUI Library)</title>
|
|
|
|
<link type="text/css" rel="stylesheet" href="../../../build/reset-fonts-grids/reset-fonts-grids.css">
|
|
|
|
<link rel="stylesheet" type="text/css" href="../../../examples/assets/dpSyntaxHighlighter.css">
|
|
<link type="text/css" rel="stylesheet" href="../assets/style.css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="doc3" class="yui-t5">
|
|
<div id="hd">
|
|
<a href="http://developer.yahoo.com/yui" id="logo"><div></div></a>
|
|
<h1>YUI Container: Using OverlayManager</h1>
|
|
</div>
|
|
|
|
<div id="bd">
|
|
|
|
<div id="toc" class="yui-b">
|
|
<ul>
|
|
<li class="sect"><a href="../index.html">YUI Container: Tutorials</a></li>
|
|
|
|
<li class="item"><a href="../module/1.html">Module: Quickstart</a></li>
|
|
<li class="item"><a href="../overlay/1.html">Overlay: Quickstart</a></li>
|
|
<li class="item"><a href="../tooltip/1.html">Tooltip: Quickstart</a></li>
|
|
<li class="item"><a href="../tooltipmulti/1.html">Tooltip: One Tooltip, Many Elements</a></li>
|
|
<li class="item"><a href="../panel/1.html">Panel: Quickstart</a></li>
|
|
<li class="item"><a href="../skin/1.html">Panel: Skinning</a></li>
|
|
<li class="item"><a href="../panelskin/1.html">Panel: Advanced Skinning using CSS</a></li>
|
|
<li class="item"><a href="../panelwait/1.html">Panel: Creating a 'Loading' Popup</a></li>
|
|
<li class="item"><a href="../panelphotobox/1.html">PhotoBox: Subclassing Panel</a></li>
|
|
<li class="item"><a href="../panelresize/1.html">ResizePanel: Creating a Resizable Panel</a></li>
|
|
<li class="item"><a href="../dialog/1.html">Dialog Quickstart</a></li>
|
|
<li class="item"><a href="../simpledialog/1.html">SimpleDialog Quickstart</a></li>
|
|
<li class="item"><a href="../effect/1.html">Using ContainerEffect</a></li>
|
|
<li class="item selected"><a href="1.html">Using OverlayManager</a></li>
|
|
<li class="child active"><a href="1.html">Managing Overlay Focus & Blur</a></li>
|
|
<li class="child"><a href="2.html">Functional Example</a></li>
|
|
<li class="item"><a href="../keylistener/1.html">Using KeyListener</a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="yui-main">
|
|
<div class="yui-b">
|
|
<h1 class="first">Managing Overlay Focus & Blur</h1>
|
|
|
|
<p>OverlayManager provides an easy way to manage multiple Overlays and keep track of which Overlay is currently in focus. When you register an Overlay with the OverlayManager, it is augmented with <em>focus</em> and <em>blur</em>, as well as two additional events, <em>focusEvent</em> and <em>blurEvent</em>. By default, clicking on an Overlay that is registered with the OverlayManager will bring it to the top by setting its z-index higher than all the other registered Overlays and will add the CSS class "focused" to its element.</p>
|
|
|
|
<p>In this tutorial, we will build three separate Panels and register them with an OverlayManager. To begin, we will instantiate three Panels that are hidden by default and render them:</p>
|
|
|
|
<textarea name="code" class="JScript" cols="60" rows="1">
|
|
// Build panel1 based on markup
|
|
YAHOO.example.container.panel1 = new YAHOO.widget.Panel("panel1", { xy:[150,100],
|
|
visible:false,
|
|
width:"300px"
|
|
} );
|
|
YAHOO.example.container.panel1.render();
|
|
|
|
// Build panel2 based on markup
|
|
YAHOO.example.container.panel2 = new YAHOO.widget.Panel("panel2", { xy:[250,200],
|
|
visible:false,
|
|
width:"300px"
|
|
} );
|
|
YAHOO.example.container.panel2.render();
|
|
|
|
// Build panel3 based on markup
|
|
YAHOO.example.container.panel3 = new YAHOO.widget.Panel("panel3", { xy:[350,300],
|
|
visible:false,
|
|
width:"300px"
|
|
} );
|
|
YAHOO.example.container.panel3.render();
|
|
</textarea>
|
|
|
|
<p>Next, we will instantiate a new OverlayManager and register the Panels as an array:</p>
|
|
|
|
<textarea name="code" class="JScript" cols="60" rows="1">
|
|
YAHOO.example.container.manager = new YAHOO.widget.OverlayManager();
|
|
YAHOO.example.container.manager.register([YAHOO.example.container.panel1,
|
|
YAHOO.example.container.panel2,
|
|
YAHOO.example.container.panel3]);
|
|
</textarea>
|
|
|
|
<p>Each of the Panels is then automatically augmented with focus and blur methods and events. Each Panel will be automatically focused when clicked, but we can also wire up buttons to focus and blur our Panels. The OverlayManager also has <em>showAll</em>, <em>hideAll</em>, and <em>blurAll</em> methods:</p>
|
|
|
|
<textarea name="code" class="HTML" cols="60" rows="1">
|
|
<div>
|
|
panel1:
|
|
<button id="show1">Show</button>
|
|
<button id="hide1">Hide</button>
|
|
<button id="focus1">Focus</button>
|
|
</div>
|
|
<div>
|
|
panel2:
|
|
<button id="show2">Show</button>
|
|
<button id="hide2">Hide</button>
|
|
<button id="focus2">Focus</button>
|
|
</div>
|
|
<div>
|
|
panel3:
|
|
<button id="show3">Show</button>
|
|
<button id="hide3">Hide</button>
|
|
<button id="focus3">Focus</button>
|
|
</div>
|
|
<div>
|
|
All Panels:
|
|
<button id="showAll">Show All</button>
|
|
<button id="hideAll">Hide All</button>
|
|
<button id="blurAll">Blur All</button>
|
|
</div>
|
|
</textarea>
|
|
|
|
|
|
<p>Finally, we will place the basic markup for our Panels, which looks identical to much of the standard module markup we've seen in previous tutorials. Note that we set the "visibility:hidden" style inline on these Panels because we don't want them to flash before they are hidden by default. Setting the style inline ensures that the Panels will not be seen in the browser until they are made visible.</p>
|
|
|
|
<textarea name="code" class="HTML" cols="60" rows="1">
|
|
<div id="panel1" style="visibility:hidden">
|
|
<div class="hd">Panel #1 from Markup</div>
|
|
<div class="bd">This is a Panel that was marked up in the document.</div>
|
|
<div class="ft">End of Panel #1</div>
|
|
</div>
|
|
|
|
<div id="panel2" style="visibility:hidden">
|
|
<div class="hd">Panel #2 from Markup</div>
|
|
<div class="bd">This is a Panel that was marked up in the document.</div>
|
|
<div class="ft">End of Panel #2</div>
|
|
</div>
|
|
|
|
<div id="panel3" style="visibility:hidden">
|
|
<div class="hd">Panel #3 from Markup</div>
|
|
<div class="bd">This is a Panel that was marked up in the document.</div>
|
|
<div class="ft">End of Panel #3</div>
|
|
</div>
|
|
</textarea>
|
|
<div id="stepnav">
|
|
<a class="next" href="2.html">Continue to <em>Functional Example</em> ></a> </div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="ft"> </div>
|
|
</div>
|
|
|
|
<script src="../../../examples/assets/dpSyntaxHighlighter.js"></script>
|
|
<script language="javascript">
|
|
dp.SyntaxHighlighter.HighlightAll('code');
|
|
</script>
|
|
|
|
</body>
|
|
</html> |