~bcsaller/juju-gui/update-reductions

« back to all changes in this revision

Viewing changes to lib/yui/docs/overlay/index.html

  • Committer: kapil.foss at gmail
  • Date: 2012-07-13 18:45:59 UTC
  • Revision ID: kapil.foss@gmail.com-20120713184559-2xl7be17egsrz0c9
reshape

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html>
2
 
<html lang="en">
3
 
<head>
4
 
    <meta charset="utf-8">
5
 
    <title>Overlay</title>
6
 
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Maven+Pro:400,700">
7
 
    <link rel="stylesheet" href="../../build/cssgrids/grids-min.css">
8
 
    <link rel="stylesheet" href="../assets/css/main.css">
9
 
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
10
 
    <script src="../../build/yui/yui-min.js"></script>
11
 
</head>
12
 
<body>
13
 
 
14
 
<div id="doc">
15
 
    <h1>Overlay</h1>
16
 
 
17
 
    
18
 
        <a href="#toc" class="jump">Jump to Table of Contents</a>
19
 
    
20
 
 
21
 
    <div class="yui3-g">
22
 
        <div class="yui3-u-3-4">
23
 
            <div id="main">
24
 
                <div class="content"><div class="intro">
25
 
    <p>Overlay is a positionable and stackable widget, which also provides support for the standard module format layout, with a header, body and footer section.
26
 
 
27
 
    <p>The overlay is built by extending the <a href="http://yuilibrary.com/yui/docs/api/Widget.html"><code>Widget</code></a> class and adding the <a href="http://yuilibrary.com/yui/docs/api/WidgetPosition.html"><code>WidgetPosition</code></a>, <a href="http://yuilibrary.com/yui/docs/api/WidgetStack.html"><code>WidgetStack</code></a>, <a href="http://yuilibrary.com/yui/docs/api/WidgetPositionAlign.html"><code>WidgetPositionAlign</code></a>, <a href="http://yuilibrary.com/yui/docs/api/WidgetPositionConstrain.html"><code>WidgetPositionConstrain</code></a> and <a href="http://yuilibrary.com/yui/docs/api/WidgetStdMod.html"><code>WidgetStdMod</code></a> extensions, 
28
 
    and doesn't actually need to add any implementation code of its own. The <a href="../widget/widget-build.html">"Creating Custom Widget Classes"</a> example shows how you can use these extensions to build classes which mix and match some of the above features.</p>
29
 
</div>
30
 
 
31
 
<h2 id="getting-started">Getting Started</h2>
32
 
 
33
 
<p>
34
 
To include the source files for Overlay and its dependencies, first load
35
 
the YUI seed file if you haven't already loaded it.
36
 
</p>
37
 
 
38
 
<pre class="code prettyprint">&lt;script src=&quot;http:&#x2F;&#x2F;yui.yahooapis.com&#x2F;3.5.1&#x2F;build&#x2F;yui&#x2F;yui-min.js&quot;&gt;&lt;&#x2F;script&gt;</pre>
39
 
 
40
 
 
41
 
<p>
42
 
Next, create a new YUI instance for your application and populate it with the
43
 
modules you need by specifying them as arguments to the <code>YUI().use()</code> method.
44
 
YUI will automatically load any dependencies required by the modules you
45
 
specify.
46
 
</p>
47
 
 
48
 
<pre class="code prettyprint">&lt;script&gt;
49
 
&#x2F;&#x2F; Create a new YUI instance and populate it with the required modules.
50
 
YUI().use(&#x27;overlay&#x27;, function (Y) {
51
 
    &#x2F;&#x2F; Overlay is available and ready for use. Add implementation
52
 
    &#x2F;&#x2F; code here.
53
 
});
54
 
&lt;&#x2F;script&gt;</pre>
55
 
 
56
 
 
57
 
<p>
58
 
For more information on creating YUI instances and on the
59
 
<a href="http://yuilibrary.com/yui/docs/api/classes/YUI.html#method_use"><code>use()</code> method</a>, see the
60
 
documentation for the <a href="../yui/index.html">YUI Global Object</a>.
61
 
</p>
62
 
 
63
 
 
64
 
<h2 id="using">Using Overlay</h2>
65
 
 
66
 
<h3 id="instantiating">Instantiating The Overlay</h3>
67
 
 
68
 
<p>The Overlay widget extends the <code>Widget</code> class, and hence the Overlay constructor follows the same pattern as any Widget constructor, accepting a configuration object to set the initial configuration for the widget.</p>
69
 
 
70
 
<h4 id="instantiating-from-markup-progressive-enhancement">Instantiating From Markup: Progressive Enhancement</h4>
71
 
 
72
 
<p>The overlay can be instantiated from markup, by specifying the <code>srcNode</code> which contains the header, body and footer content for the overlay:</p>
73
 
 
74
 
<pre class="code prettyprint">&lt;div id=&quot;myContent&quot;&gt;
75
 
    &lt;div class=&quot;yui3-widget-hd&quot;&gt;Overlay Header&lt;&#x2F;div&gt;
76
 
    &lt;div class=&quot;yui3-widget-bd&quot;&gt;Overlay Body&lt;&#x2F;div&gt;
77
 
    &lt;div class=&quot;yui3-widget-ft&quot;&gt;Overlay Footer&lt;&#x2F;div&gt;
78
 
&lt;&#x2F;div&gt;</pre>
79
 
 
80
 
 
81
 
<p>The header, body and footer sections provided in markup need to be marked with the class name which <code>Overlay</code> (or more accurately, <code>WidgetStdMod</code>) expects for the section ("yui3-widget-hd", "yui3-widget-bd" and "yui3-widget-ft") as shown above. 
82
 
All of these sections are optional. If content is set via the API at a later point the corresponding section will be created dynamically.</p>
83
 
 
84
 
<p>When instantiating from markup, a reference to the <code>srcNode</code> is provided in the configuration object. This reference can be a node reference, or a selector string which can be used to identify the node. If the selector string is too broad (returns multiple nodes), the first node found will be used.
85
 
The following code targets the markup shown above:</p>
86
 
 
87
 
<pre class="code prettyprint">YUI({...}).use(&quot;overlay&quot;, function(Y) {
88
 
 
89
 
    &#x2F;&#x2F;...
90
 
    var overlay = new Y.Overlay({
91
 
        &#x2F;&#x2F; Specify a reference to a node which already exists 
92
 
        &#x2F;&#x2F; on the page and contains header&#x2F;body&#x2F;footer content
93
 
        srcNode:&quot;#myContent&quot;,
94
 
 
95
 
        &#x2F;&#x2F; Also set some of the attributes inherited from
96
 
        &#x2F;&#x2F; the base Widget class.
97
 
        visible:false,
98
 
        width:&quot;20em&quot;
99
 
    });
100
 
    &#x2F;&#x2F;...
101
 
 
102
 
});</pre>
103
 
 
104
 
 
105
 
<p>Following instantiation, a call to <code>render</code> is required to have the Overlay's state reflected in the DOM, as with all YUI 3 widgets:</p>
106
 
 
107
 
<pre class="code prettyprint">var overlay = new Y.Overlay({ ... });
108
 
overlay.render();</pre>
109
 
 
110
 
 
111
 
<p>Note that you could set the state of the Overlay multiple times (modifying content, changing dimensions etc.) before rendering. 
112
 
When the <code>render</code> method is invoked, the state of the Overlay at that point in time will be reflected in the DOM.</p>
113
 
 
114
 
<p>When <code>render</code> is invoked, the overlay's content box will be wrapped by the bounding box (another DIV), to provide the <a href="../widget/index.html#markup">nested box structure</a> common to all widgets.</p>
115
 
 
116
 
<h4 id="instantiating-from-script">Instantiating From Script</h4>
117
 
 
118
 
<p>You can also create Overlay instances entirely from script, setting content programmatically, using the <code>headerContent</code>, <code>bodyContent</code> and <code>footerContent</code> attributes.</p>
119
 
 
120
 
<pre class="code prettyprint">var overlay = new Y.Overlay({
121
 
    headerContent:&quot;My Overlay Header&quot;,
122
 
    bodyContent:&quot;My Overlay Body&quot;,
123
 
    footerContent:&quot;My Footer Content&quot;,
124
 
    &#x2F;&#x2F;...
125
 
});
126
 
overlay.render(&quot;#parentNode&quot;);</pre>
127
 
 
128
 
 
129
 
<p>Content can be strings containing markup (innerHTML will be used to set the content), or <code>Node</code> references, in which case they will be appended to the section (header, body or footer) node.</p>
130
 
 
131
 
<p>The <code>render</code> method can be passed a node reference (or a selector string) as shown above, to specify the node
132
 
under which the overlay's bounding box should be added to the DOM. When rendering an overlay instance which has not been created from markup 
133
 
(so it does not have a position in the DOM) if this argument is not provided the overlay will be added to the document's body element (inserted as the first child to avoid the potential for "operation aborted" errors in IE6).
134
 
</p>
135
 
 
136
 
<h3 id="attributes">Attributes</h3>
137
 
 
138
 
<p>Overlay adds the following key attributes (through the extensions mentioned above), in addition to the attributes provided by the base <a href="../widget/index.html#attributes">Widget</a> class:</p>
139
 
 
140
 
<table>
141
 
    <tr><th>Attribute</th><th>Description</th></tr>
142
 
    <tr><td><code>x</code>, <code>y</code> and <code>xy</code></td><td>Positioning attributes, to set the XY position in page coordinates on the Overlay's bounding box. Set to [0,0] by default</td></tr>
143
 
    <tr><td><code>zIndex</code></td><td>Sets the z-index on the Overlay's bounding box. Set to 0 by default.</td></tr>
144
 
    <tr><td><code>shim</code></td><td>Boolean, indicating whether or not an iframe shim should be added to the Overlay to protect against select box bleed through. It is only enabled by default for IE6.</td></tr>
145
 
    <tr><td><code>align</code></td><td>Used to align a specific point on the Overlay's bounding box to a specific point on another node, or the viewport. Set to null by default.</td></tr>
146
 
    <tr><td><code>centered</code></td><td>Used to center the Overlay inside another node, or inside the viewport. Set to false by default.</td></tr>
147
 
    <tr><td><code>constrain</code></td><td>Used to specify a node to constrain the Overlay to, when setting the XY position. Can also be set to true, to constrain to the viewport. Set to false by default.</td></tr>
148
 
    <tr><td><code>headerContent</code></td><td>Used to set the content of the Overlay's header section. No default value set.</td></tr>
149
 
    <tr><td><code>bodyContent</code></td><td>Used to set the content of the Overlay's body section. No default value set.</td></tr>
150
 
    <tr><td><code>footerContent</code></td><td>Used to set the content of the Overlay's footer section. No default value set.</td></tr>
151
 
    <tr><td><code>fillHeight</code></td><td>Specifies which of the 3 sections - header, body or footer, should be automatically sized to fill out the height of the Overlay if a fixed height has been set. Set to WidgetStdMod.BODY by default. Can be disabled by setting to null.</td></tr>
152
 
</table>
153
 
 
154
 
<h3 id="positioning">Positioning</h3>
155
 
 
156
 
<h4 id="basic-xy-positioning">Basic XY Positioning</h4>
157
 
 
158
 
<p>Overlay provides basic XY positioning support through its <code>x</code>, <code>y</code> and <code>xy</code> attributes as well as a convenience <code>move</code> method which wraps the <code>xy</code> attribute.</p>
159
 
 
160
 
<p>The xy position of the overlay can be set in the constructor, as with any attribute value:</p>
161
 
 
162
 
<pre class="code prettyprint">var overlay = new Y.Overlay({
163
 
    srcNode:&quot;#myContent&quot;,
164
 
    xy: [200,100]
165
 
});
166
 
overlay.render();
167
 
 
168
 
&#x2F;&#x2F; or
169
 
 
170
 
var overlay = new Y.Overlay({
171
 
    srcNode:&quot;#myContent&quot;,
172
 
    x: 200,
173
 
    y: 100
174
 
});
175
 
overlay.render();
176
 
 
177
 
&#x2F;&#x2F; or
178
 
 
179
 
var overlay = new Y.Overlay({
180
 
    srcNode:&quot;#myContent&quot;,
181
 
    x: 200 &#x2F;&#x2F; y defaults to 0
182
 
});
183
 
overlay.render();</pre>
184
 
 
185
 
 
186
 
<p>The overlay's default position, if xy values are not provided, will be 0,0. Note that xy are page coordinates, not relative coordinates.</p>
187
 
 
188
 
<p>Changes in the overlay's position, when set programmatically through the API, can be monitored by listening for the attribute <code>xyChange</code> event. Listeners
189
 
to this event will receive an event facade, which contains previous and new xy values:</p>
190
 
 
191
 
<pre class="code prettyprint">&#x2F;&#x2F; Listen to the &quot;on&quot; moment, if you&#x27;re interested in
192
 
&#x2F;&#x2F; preventing the change in position from occurring.
193
 
overlay.on(&quot;xyChange&quot;, function(e) {
194
 
 
195
 
    var currPosition = e.prevVal;
196
 
    var newPosition = e.newVal;
197
 
 
198
 
    if (newPosition[0] &gt; MAX_X || newPosition[1] &gt; MAX_Y) {
199
 
        &#x2F;&#x2F; Stop move from occurring. 
200
 
        e.preventDefault();
201
 
    }
202
 
});
203
 
 
204
 
&#x2F;&#x2F; Listen to the &quot;after&quot; moment, if you&#x27;re just interested 
205
 
&#x2F;&#x2F; in being notified when the position has been changed.
206
 
overlay.after(&quot;xyChange&quot;, function(e) {
207
 
    var position = e.newVal;
208
 
    console.log(&quot;Overlay has been moved to: &quot; + position[0] + &quot;,&quot; position[1]);
209
 
});</pre>
210
 
 
211
 
 
212
 
<p>Note that changing just the <code>x</code> or <code>y</code> attribute value, individually, will still fire the <code>xy</code> change event. The <code>x</code> and 
213
 
<code>y</code> attribute values are simply convenience wrappers which end up setting the <code>xy</code> attribute.</p>
214
 
 
215
 
<p>XY position can also be set after construction, as with any attribute, using <code>set</code> to change the attribute value directly, or using the <code>move</code> method:</p>
216
 
 
217
 
<pre class="code prettyprint">overlay.set(&quot;x&quot;, 100);
218
 
 
219
 
overlay.set(&quot;y&quot;, 200);
220
 
 
221
 
overlay.set(&quot;xy&quot;, [100,200]);
222
 
 
223
 
overlay.move(100,200);
224
 
 
225
 
overlay.move([100,200]);</pre>
226
 
 
227
 
 
228
 
<p>The <a href="overlay-xy.html">Basic XY Positioning</a> example shows basic positioning in action.</p>
229
 
 
230
 
<h4 id="extended-xy-positioning">Extended XY Positioning</h4>
231
 
 
232
 
<p>Overlay also provides support to help position it relative to another node on the page, or the viewport, through the <code>align</code> and <code>centered</code> attributes, as well as 
233
 
the corresponding <code>align()</code> and <code>centered()</code> convenience methods, through the application of the <code>WidgetPositionAlign</code> extension.</p>
234
 
 
235
 
<p>The <code>align</code> attribute accepts as a value an object literal with the following properties:</p>
236
 
<dl>
237
 
    <dt>node</dt>
238
 
    <dd>
239
 
      The node to which the Widget is to be aligned. If set to null, or not provided, the Overlay is aligned to the viewport
240
 
    </dd>
241
 
    <dt>points</dt>
242
 
    <dd>
243
 
      <p>
244
 
      A two element array, defining the two points on the Overlay and node which are to be aligned. The first element is the point on the Overlay, and the second element is the point on the node (or viewport).
245
 
      Supported alignment points are defined as static properties on <a href="http://yuilibrary.com/yui/docs/api/WidgetPositionAlign.html#property_WidgetPositionAlign.TL"><code>WidgetPositionAlign</code></a>. For example:
246
 
      </p>
247
 
      <p>
248
 
      <code>[Y.WidgetPositionAlign.TR, Y.WidgetPositionAlign.TL]</code> aligns the Top-Right corner of the Overlay with the
249
 
      Top-Left corner of the node/viewport, and <code>[Y.WidgetPositionAlign.CC, Y.WidgetPositionAlign.TC]</code> aligns the Center of the 
250
 
      Overlay with the Top-Center edge of the node/viewport.
251
 
      </p>
252
 
    </dd>
253
 
</dl>
254
 
 
255
 
<pre class="code prettyprint">&#x2F;&#x2F; Align the:
256
 
&#x2F;&#x2F; top-left corner of the overlay, with the 
257
 
&#x2F;&#x2F; top-right corner of the node with id = &quot;okBtn&quot;
258
 
overlay.set(&quot;align&quot;, {
259
 
    node:&quot;#okBtn&quot;,
260
 
    points:[Y.WidgetPositionAlign.TL, Y.WidgetPositionAlign.TR]
261
 
});
262
 
 
263
 
&#x2F;&#x2F; Align the:
264
 
&#x2F;&#x2F; right-center edge of the overlay, with the 
265
 
&#x2F;&#x2F; right-center edge of the viewport (no node specified)
266
 
overlay.set(&quot;align&quot;, {
267
 
    points:[Y.WidgetPositionAlign.RC, Y.WidgetPositionAlign.RC]
268
 
});
269
 
 
270
 
&#x2F;&#x2F; Align the:
271
 
&#x2F;&#x2F; center of the overlay, with the 
272
 
&#x2F;&#x2F; top-left corner of the node with id = &quot;okBtn&quot;
273
 
overlay.align(&quot;#okBtn&quot;, [Y.WidgetPositionAlign.CC, Y.WidgetPositionAlign.TL]);</pre>
274
 
 
275
 
 
276
 
<p>The <code>centered</code> property can either by set to <code>true</code> to center the Overlay in the viewport, or set to a selector string or node reference to center the Overlay in a particular node.</p>
277
 
 
278
 
<pre class="code prettyprint">&#x2F;&#x2F; Center the overlay in the node with id = &quot;module&quot;
279
 
overlay.set(&quot;centered&quot;, &quot;#module&quot;);
280
 
 
281
 
&#x2F;&#x2F; Center the overlay in the viewport
282
 
overlay.set(&quot;centered&quot;, true);</pre>
283
 
 
284
 
 
285
 
<p>The <a href="overlay-align.html">"Alignment Support"</a> example shows aligned positioning support in action.</p>
286
 
 
287
 
<p>Note that currently alignment/centering is not maintained when the viewport is scrolled, window resized etc. Support to re-align the overlay on a default and custom set of trigger events will be 
288
 
provided in a future release.</p>
289
 
 
290
 
<p>In addition to being able to align the overlay to a given element (or the viewport), overlay also supports the ability to constrain its XY position to a given node, or to the viewport.</p>
291
 
 
292
 
<pre class="code prettyprint">&#x2F;&#x2F; Constrains the XY position to a given node:
293
 
overlay.set(&quot;constrain&quot;, &quot;#constrainingNode&quot;);
294
 
 
295
 
&#x2F;&#x2F; Or to the viewport
296
 
overlay.set(&quot;constrain&quot;, true);</pre>
297
 
 
298
 
 
299
 
<p>The <a href="overlay-constrain.html">"Constrain Support"</a> example shows constrained positioning in action.</p>
300
 
 
301
 
<h3 id="stacking">Stacking</h3>
302
 
 
303
 
<p>
304
 
The Overlay provides basic stacking support in the form of a <code>zIndex</code> attribute and a <code>shim</code> attribute. The shimming support protects against &lt;select&gt; box bleed through on 
305
 
IE6 (It is enabled by default for IE6) by adding an iframe shim to the overlay's bounding box (positioned underneath the content box). The default value of the <code>zIndex</code> attribute is 0.</p>
306
 
 
307
 
<p>Using the <code>zIndex</code> and <code>shim</code> attributes is the same as any other attribute, with the ability to set values in the constructor, or at a later point in time:</p>
308
 
 
309
 
<pre class="code prettyprint">&#x2F;&#x2F; Disable shim for all browsers, set zIndex to 10
310
 
var overlay = new Y.Overlay({
311
 
    shim:false, &#x2F;&#x2F; Disable for all browsers, including IE6
312
 
    zIndex:10
313
 
});
314
 
 
315
 
&#x2F;&#x2F; Set zIndex to 10. Shim is enabled for IE6 but disabled for all
316
 
&#x2F;&#x2F; other browsers (default value)
317
 
var overlay = new Y.Overlay({
318
 
    zIndex:10
319
 
});</pre>
320
 
 
321
 
 
322
 
<p>The <a href="overlay-stack.html">"Stack Support"</a> example creates a simple "bringToTop" implementation based on the <code>zIndex</code> attribute. 
323
 
This support will be provided as part of Overlay itself (or more precisely, as part of <code>WidgetStack</code>) in a future release.</p>
324
 
 
325
 
<h3 id="content">Setting Section Content</h3>
326
 
 
327
 
<p>Overlay uses the standard module format for its rendering. It provides a header, body and footer section as described above (through the <code>WidgetStdMod</code> extension).</p>
328
 
 
329
 
<h4 id="replacing-content">Replacing Content</h4>
330
 
 
331
 
<p>The content for each of these sections is settable either through the <code>headerContent</code>, <code>bodyContent</code> and <code>footerContent</code> attributes. Setting the content
332
 
through these properties will replace any existing content in the section. The content can either be specified as a string, in which case innerHTML will be used to set the new content, or 
333
 
specified as a <code>Node</code> instance, in which case the content will be added to the respective section using <code>appendChild</code> after clearing existing content.</p>
334
 
 
335
 
<pre class="code prettyprint">var overlay = new Y.Overlay({
336
 
    headerContent: &#x27;&lt;span class=&quot;title&quot;&gt;My Header Content&lt;&#x2F;span&gt;&#x27;,
337
 
    bodyContent: &#x27;&lt;div class=&quot;mod&quot;&gt;My Body Content&lt;&#x2F;div&gt;&#x27;
338
 
    &#x2F;&#x2F; Don&#x27;t want a footer
339
 
});
340
 
 
341
 
&#x2F;&#x2F; or 
342
 
 
343
 
overlay.set(&quot;headerContent&quot;, &#x27;&lt;span class=&quot;title&quot;&gt;My Header Content&lt;&#x2F;span&gt;&#x27;);
344
 
 
345
 
&#x2F;&#x2F; or 
346
 
 
347
 
var headerContent = Y.Node.create(&quot;&lt;span&gt;&lt;&#x2F;span&gt;&quot;);
348
 
headerContent.set(&quot;innerHTML&quot;, &quot;My Header Content&quot;);
349
 
headerContent.addClass(&quot;title&quot;); 
350
 
 
351
 
overlay.set(&quot;headerContent&quot;, headerContent);</pre>
352
 
 
353
 
            
354
 
<p>Overlay will not create the section if there has been no content set for it. (So, for example, the overlay above will not have a footer section). Also, if the section doesn't exist it will be created,
355
 
the first time content is set for it.</p>
356
 
 
357
 
<p>As with any attribute change, you can listen for (and prevent) changes in content by listening for the corresponding attribute change event:</p>
358
 
 
359
 
<pre class="code prettyprint">overlay.on(&quot;bodyContentChange&quot;, function(e) {
360
 
    if (someCondition) {
361
 
        &#x2F;&#x2F; Don&#x27;t allow body content to be updated
362
 
        e.preventDefault():
363
 
    }
364
 
});
365
 
 
366
 
overlay.after(&quot;bodyContentChange&quot;, function(e) {
367
 
    &#x2F;&#x2F; body section has been modified
368
 
});</pre>
369
 
 
370
 
 
371
 
<p>Setting content in any of the sections will fire Widget's <code>contentUpdate</code> event, which can be monitored if you want to be notified of changes to any section. However, this event is purely a catch-all notification
372
 
event. It cannot be prevented to stop the content change from occurring:</p>
373
 
 
374
 
<pre class="code prettyprint">overlay.after(&quot;contentUpdate&quot;, function(e) {
375
 
    &#x2F;&#x2F; Content has been updated in one of the standard module sections.
376
 
});</pre>
377
 
 
378
 
 
379
 
<h4 id="insertingappending-content">Inserting/Appending Content</h4>
380
 
 
381
 
<p>Setting content using the attributes mentioned above always results in content being replaced. If you need to insert content before, or append content after existing content in the section, you can use the <code>setStdModContent(section, content, where)</code> method Overlay provides:</p>
382
 
 
383
 
<pre class="code prettyprint">overlay.setStdModContent(
384
 
    Y.WidgetStdMod.HEADER,       &#x2F;&#x2F; Section
385
 
    &quot;New Content To Insert&quot;,   &#x2F;&#x2F; Content
386
 
    Y.WidgetStdMod.BEFORE        &#x2F;&#x2F; Where
387
 
);
388
 
 
389
 
overlay.setStdModContent(
390
 
    Y.WidgetStdMod.FOOTER,      &#x2F;&#x2F; Section
391
 
    &quot;New Content To Append&quot;,  &#x2F;&#x2F; Content
392
 
    Y.WidgetStdMod.AFTER        &#x2F;&#x2F; Where
393
 
);</pre>
394
 
 
395
 
 
396
 
<ul>
397
 
    <li>The <code>section</code> argument specifies which section is to be updated. The constants <code>WidgetStdMod.HEADER</code>, <code>WidgetStdMod.BODY</code> and <code>WidgetStdMod.FOOTER</code> define valid values.</li>
398
 
    <li>The <code>content</code> argument specifies the new content to be added which, as with the attributes, can be a string HTML value or a node reference.</li>
399
 
    <li>The <code>where</code> argument specifies whether the content should be added before, after, or replace existing content. The constants <code>WidgetStdMod.BEFORE</code>, <code>WidgetStdMod.AFTER</code> and <code>WidgetStdMod.REPLACE</code></p> define valid values.</li>
400
 
</ul>
401
 
 
402
 
<p><em>Note, the above <code>WidgetStdMod</code> constants define the set of valid values wherever the API expects a "section" or "where" argument.</em></p>
403
 
 
404
 
<p>The content change events mentioned above, will be fired when content is set through the <code>setStdModContent</code> method just as they would when setting the content using the attribute.</p>
405
 
 
406
 
<p>The <a href="overlay-stdmod.html">Standard Module</a> example provides a way to exercise the above content attributes and methods.</p>
407
 
 
408
 
<h3 id="markup">Markup Structure</h3>
409
 
 
410
 
<p>The final rendered Overlay has the markup structure shown below:</p>
411
 
 
412
 
<pre class="code prettyprint">&lt;div class=&quot;yui3-widget yui3-overlay yui3-widget-positioned yui3-widget-stacked&quot;&gt;
413
 
    &lt;!--Bounding Box--&gt;
414
 
    &lt;div class=&quot;yui3-overlay-content yui3-widget-stdmod&quot;&gt;
415
 
    &lt;!--Content Box--&gt;
416
 
        &lt;div class=&quot;yui3-widget-hd&quot;&gt;Overlay Header Content&lt;&#x2F;div&gt;
417
 
            &lt;!--Header Section--&gt;
418
 
        &lt;div class=&quot;yui3-widget-bd&quot;&gt;Overlay Body Content&lt;&#x2F;div&gt;
419
 
            &lt;!--Body Section--&gt;
420
 
        &lt;div class=&quot;yui3-widget-ft&quot;&gt;Overlay Footer Content&lt;&#x2F;div&gt;
421
 
            &lt;!--Footer Section--&gt;
422
 
    &lt;&#x2F;div&gt;
423
 
 
424
 
    &lt;iframe class=&quot;yui3-widget-shim&quot;&gt;&lt;&#x2F;iframe&gt;
425
 
        &lt;!-- Stacking shim, if enabled--&gt;
426
 
 
427
 
&lt;&#x2F;div&gt;</pre>
428
 
 
429
 
 
430
 
<p>The bounding box is absolutely positioned by default, and top/left positioning and z-index values are applied to it. The nested bounding box/content box structure is discussed in detail on the <a href="../widget/index.html#markup">Widget markup discussion</a>.</p>
431
 
 
432
 
<p>In addition to the default classes applied to the bounding box and content box for all widgets ("yui3-overlay", "yui3-overlay-content", "yui3-widget"), the <code>WidgetStdMod</code>, <code>WidgetPositioned</code> and <code>WidgetStack</code> extensions also mark the appropriate boxes with 
433
 
"yui3-widget-stdmod", "yui3-widget-positioned" and "yui3-widget-stacked" classes as shown above.</p>
434
 
 
435
 
<p>The iframe shim, added if <code>shim</code> is enabled, is added to the bounding box, as sibling to the content box and stacked underneath it (using a -ve z-index).</p>
436
 
 
437
 
<h3 id="css">CSS</h3>
438
 
 
439
 
<p>Overlay is a generic, foundation widget and doesn't ship with a default look/feel out of the box. Its Sam Skin (build/overlay/assets/skins/sam/overlay.css) implementation consists only of core functional rules, to control how it is positioned and how it is hidden:</p>
440
 
 
441
 
<pre class="code prettyprint">.yui3-overlay {
442
 
    position:absolute;
443
 
}
444
 
 
445
 
.yui3-overlay-hidden {
446
 
    visibility:hidden
447
 
}</pre>
448
 
 
449
 
 
450
 
<p>Since it includes the <code>WidgetStack</code> extension, the following functional CSS is also provided (through build/widget/assets/skins/sam/widget-stack.css) to handle the shim element,
451
 
(along with the Gecko/Mac scroll bar support CSS mentioned above)</p>
452
 
 
453
 
<pre class="code prettyprint">.yui3-widget-stacked .yui3-widget-shim {
454
 
    opacity: 0;
455
 
    filter: alpha(opacity=0);
456
 
    position: absolute;
457
 
    border: none;
458
 
    top: 0px;
459
 
    left: 0px;
460
 
    padding: 0;
461
 
    margin: 0;
462
 
    z-index: -1;
463
 
    width: 100%;
464
 
    height: 100%;
465
 
    &#x2F;* 
466
 
       We&#x27;ll be setting these programmatically for IE6, 
467
 
       to account for cases where height is not set 
468
 
    *&#x2F;
469
 
    _width: 0;
470
 
    _height: 0;
471
 
}</pre>
472
 
 
473
 
</div>
474
 
            </div>
475
 
        </div>
476
 
 
477
 
        <div class="yui3-u-1-4">
478
 
            <div class="sidebar">
479
 
                
480
 
                    <div id="toc" class="sidebox">
481
 
                        <div class="hd">
482
 
                            <h2 class="no-toc">Table of Contents</h2>
483
 
                        </div>
484
 
 
485
 
                        <div class="bd">
486
 
                            <ul class="toc">
487
 
<li>
488
 
<a href="#getting-started">Getting Started</a>
489
 
</li>
490
 
<li>
491
 
<a href="#using">Using Overlay</a>
492
 
<ul class="toc">
493
 
<li>
494
 
<a href="#instantiating">Instantiating The Overlay</a>
495
 
<ul class="toc">
496
 
<li>
497
 
<a href="#instantiating-from-markup-progressive-enhancement">Instantiating From Markup: Progressive Enhancement</a>
498
 
</li>
499
 
<li>
500
 
<a href="#instantiating-from-script">Instantiating From Script</a>
501
 
</li>
502
 
</ul>
503
 
</li>
504
 
<li>
505
 
<a href="#attributes">Attributes</a>
506
 
</li>
507
 
<li>
508
 
<a href="#positioning">Positioning</a>
509
 
<ul class="toc">
510
 
<li>
511
 
<a href="#basic-xy-positioning">Basic XY Positioning</a>
512
 
</li>
513
 
<li>
514
 
<a href="#extended-xy-positioning">Extended XY Positioning</a>
515
 
</li>
516
 
</ul>
517
 
</li>
518
 
<li>
519
 
<a href="#stacking">Stacking</a>
520
 
</li>
521
 
<li>
522
 
<a href="#content">Setting Section Content</a>
523
 
<ul class="toc">
524
 
<li>
525
 
<a href="#replacing-content">Replacing Content</a>
526
 
</li>
527
 
<li>
528
 
<a href="#insertingappending-content">Inserting/Appending Content</a>
529
 
</li>
530
 
</ul>
531
 
</li>
532
 
<li>
533
 
<a href="#markup">Markup Structure</a>
534
 
</li>
535
 
<li>
536
 
<a href="#css">CSS</a>
537
 
</li>
538
 
</ul>
539
 
</li>
540
 
</ul>
541
 
                        </div>
542
 
                    </div>
543
 
                
544
 
 
545
 
                
546
 
                    <div class="sidebox">
547
 
                        <div class="hd">
548
 
                            <h2 class="no-toc">Examples</h2>
549
 
                        </div>
550
 
 
551
 
                        <div class="bd">
552
 
                            <ul class="examples">
553
 
                                
554
 
                                    
555
 
                                        <li data-description="Shows how to instantiate a basic Overlay instance, and use the Overlay&#x27;s basic XY positioning support.">
556
 
                                            <a href="overlay-xy.html">Basic XY Positioning</a>
557
 
                                        </li>
558
 
                                    
559
 
                                
560
 
                                    
561
 
                                        <li data-description="Shows how to create a simple tooltip incorporating the overlay shim feature.">
562
 
                                            <a href="overlay-tooltip.html">Simple Tooltip</a>
563
 
                                        </li>
564
 
                                    
565
 
                                
566
 
                                    
567
 
                                        <li data-description="Shows how to use the Overlay&#x27;s XY alignment support, to align the Overlay relative to another element, or to the viewport.">
568
 
                                            <a href="overlay-align.html">Alignment Support</a>
569
 
                                        </li>
570
 
                                    
571
 
                                
572
 
                                    
573
 
                                        <li data-description="Shows how to use the Overlay&#x27;s zindex and shim support when positioning Overlays above other elements on the page.">
574
 
                                            <a href="overlay-stack.html">Stack Support</a>
575
 
                                        </li>
576
 
                                    
577
 
                                
578
 
                                    
579
 
                                        <li data-description="Shows how to modify content in the Overlay&#x27;s header, body and footer sections.">
580
 
                                            <a href="overlay-stdmod.html">Standard Module Support</a>
581
 
                                        </li>
582
 
                                    
583
 
                                
584
 
                                    
585
 
                                        <li data-description="Shows how to use Overlay&#x27;s constrainment support, to limit the XY value which can be set for an Overlay.">
586
 
                                            <a href="overlay-constrain.html">Constrain Support</a>
587
 
                                        </li>
588
 
                                    
589
 
                                
590
 
                                    
591
 
                                        <li data-description="Shows how to create a simple plugin to retrieve content for the Overlay using the io utility.">
592
 
                                            <a href="overlay-io-plugin.html">IO Plugin</a>
593
 
                                        </li>
594
 
                                    
595
 
                                
596
 
                                    
597
 
                                        <li data-description="Shows how to create a simple plugin to animate the Overlay&#x27;s movement and visibility.">
598
 
                                            <a href="overlay-anim-plugin.html">Animation Plugin</a>
599
 
                                        </li>
600
 
                                    
601
 
                                
602
 
                                    
603
 
                                
604
 
                                    
605
 
                                
606
 
                            </ul>
607
 
                        </div>
608
 
                    </div>
609
 
                
610
 
 
611
 
                
612
 
                    <div class="sidebox">
613
 
                        <div class="hd">
614
 
                            <h2 class="no-toc">Examples That Use This Component</h2>
615
 
                        </div>
616
 
 
617
 
                        <div class="bd">
618
 
                            <ul class="examples">
619
 
                                
620
 
                                    
621
 
                                
622
 
                                    
623
 
                                
624
 
                                    
625
 
                                
626
 
                                    
627
 
                                
628
 
                                    
629
 
                                
630
 
                                    
631
 
                                
632
 
                                    
633
 
                                
634
 
                                    
635
 
                                
636
 
                                    
637
 
                                        <li data-description="Creating an accessible menu button using the Focus Manager Node Plugin, Event&#x27;s delegation support and mouseenter event, along with the Overlay widget and Node&#x27;s support for the WAI-ARIA Roles and States.">
638
 
                                            <a href="../node-focusmanager/node-focusmanager-3.html">Accessible Menu Button</a>
639
 
                                        </li>
640
 
                                    
641
 
                                
642
 
                                    
643
 
                                        <li data-description="Use StyleSheet to adjust the CSS rules applying a page theme from user input">
644
 
                                            <a href="../stylesheet/stylesheet-theme.html">Adjusting a Page Theme on the Fly</a>
645
 
                                        </li>
646
 
                                    
647
 
                                
648
 
                            </ul>
649
 
                        </div>
650
 
                    </div>
651
 
                
652
 
            </div>
653
 
        </div>
654
 
    </div>
655
 
</div>
656
 
 
657
 
<script src="../assets/vendor/prettify/prettify-min.js"></script>
658
 
<script>prettyPrint();</script>
659
 
 
660
 
</body>
661
 
</html>