~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/build/widget-stdmod/widget-stdmod.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.4.1 (build 4118)
3
 
Copyright 2011 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('widget-stdmod', function(Y) {
8
 
 
9
 
/**
10
 
 * Provides standard module support for Widgets through an extension.
11
 
 * 
12
 
 * @module widget-stdmod
13
 
 */
14
 
    var L = Y.Lang,
15
 
        Node = Y.Node,
16
 
        UA = Y.UA,
17
 
        Widget = Y.Widget,
18
 
 
19
 
        EMPTY = "",
20
 
        HD = "hd",
21
 
        BD = "bd",
22
 
        FT = "ft",
23
 
        HEADER = "header",
24
 
        BODY = "body",
25
 
        FOOTER = "footer",
26
 
        FILL_HEIGHT = "fillHeight",
27
 
        STDMOD = "stdmod",
28
 
        
29
 
        NODE_SUFFIX = "Node",
30
 
        CONTENT_SUFFIX = "Content",
31
 
 
32
 
        FIRST_CHILD = "firstChild",
33
 
        CHILD_NODES = "childNodes",
34
 
        OWNER_DOCUMENT = "ownerDocument",
35
 
 
36
 
        CONTENT_BOX = "contentBox",
37
 
 
38
 
        HEIGHT = "height",
39
 
        OFFSET_HEIGHT = "offsetHeight",
40
 
        AUTO = "auto",
41
 
 
42
 
        HeaderChange = "headerContentChange",
43
 
        BodyChange = "bodyContentChange",
44
 
        FooterChange = "footerContentChange",
45
 
        FillHeightChange = "fillHeightChange",
46
 
        HeightChange = "heightChange",
47
 
        ContentUpdate = "contentUpdate",
48
 
 
49
 
        RENDERUI = "renderUI",
50
 
        BINDUI = "bindUI",
51
 
        SYNCUI = "syncUI",
52
 
 
53
 
        APPLY_PARSED_CONFIG = "_applyParsedConfig",
54
 
 
55
 
        UI = Y.Widget.UI_SRC;
56
 
 
57
 
    /**
58
 
     * Widget extension, which can be used to add Standard Module support to the 
59
 
     * base Widget class, through the <a href="Base.html#method_build">Base.build</a> 
60
 
     * method.
61
 
     * <p>
62
 
     * The extension adds header, body and footer sections to the Widget's content box and 
63
 
     * provides the corresponding methods and attributes to modify the contents of these sections.
64
 
     * </p>
65
 
     * @class WidgetStdMod
66
 
     * @param {Object} The user configuration object
67
 
     */
68
 
    function StdMod(config) {
69
 
 
70
 
        this._stdModNode = this.get(CONTENT_BOX);
71
 
 
72
 
        Y.before(this._renderUIStdMod, this, RENDERUI);
73
 
        Y.before(this._bindUIStdMod, this, BINDUI);
74
 
        Y.before(this._syncUIStdMod, this, SYNCUI);
75
 
    }
76
 
 
77
 
    /**
78
 
     * Constant used to refer the the standard module header, in methods which expect a section specifier
79
 
     * 
80
 
     * @property HEADER
81
 
     * @static
82
 
     * @type String
83
 
     */
84
 
    StdMod.HEADER = HEADER;
85
 
 
86
 
    /**
87
 
     * Constant used to refer the the standard module body, in methods which expect a section specifier
88
 
     * 
89
 
     * @property BODY
90
 
     * @static
91
 
     * @type String
92
 
     */
93
 
    StdMod.BODY = BODY;
94
 
 
95
 
    /**
96
 
     * Constant used to refer the the standard module footer, in methods which expect a section specifier
97
 
     * 
98
 
     * @property FOOTER
99
 
     * @static
100
 
     * @type String
101
 
     */
102
 
    StdMod.FOOTER = FOOTER;
103
 
 
104
 
    /**
105
 
     * Constant used to specify insertion position, when adding content to sections of the standard module in 
106
 
     * methods which expect a "where" argument.
107
 
     * <p>
108
 
     * Inserts new content <em>before</em> the sections existing content.
109
 
     * </p>
110
 
     * @property AFTER
111
 
     * @static
112
 
     * @type String
113
 
     */
114
 
    StdMod.AFTER = "after";
115
 
 
116
 
    /**
117
 
     * Constant used to specify insertion position, when adding content to sections of the standard module in
118
 
     * methods which expect a "where" argument.
119
 
     * <p>
120
 
     * Inserts new content <em>before</em> the sections existing content.
121
 
     * </p>
122
 
     * @property BEFORE
123
 
     * @static
124
 
     * @type String
125
 
     */
126
 
    StdMod.BEFORE = "before";
127
 
    /**
128
 
     * Constant used to specify insertion position, when adding content to sections of the standard module in
129
 
     * methods which expect a "where" argument.
130
 
     * <p>
131
 
     * <em>Replaces</em> the sections existing content, with new content.
132
 
     * </p>
133
 
     * @property REPLACE
134
 
     * @static
135
 
     * @type String
136
 
     */
137
 
    StdMod.REPLACE = "replace";
138
 
 
139
 
    var STD_HEADER = StdMod.HEADER,
140
 
        STD_BODY = StdMod.BODY,
141
 
        STD_FOOTER = StdMod.FOOTER,
142
 
        
143
 
        HEADER_CONTENT = STD_HEADER + CONTENT_SUFFIX,
144
 
        FOOTER_CONTENT = STD_FOOTER + CONTENT_SUFFIX,
145
 
        BODY_CONTENT = STD_BODY + CONTENT_SUFFIX;
146
 
 
147
 
    /**
148
 
     * Static property used to define the default attribute 
149
 
     * configuration introduced by WidgetStdMod.
150
 
     * 
151
 
     * @property ATTRS
152
 
     * @type Object
153
 
     * @static
154
 
     */
155
 
    StdMod.ATTRS = {
156
 
 
157
 
        /**
158
 
         * @attribute headerContent
159
 
         * @type {String | Node}
160
 
         * @default undefined
161
 
         * @description The content to be added to the header section. This will replace any existing content
162
 
         * in the header. If you want to append, or insert new content, use the <a href="#method_setStdModContent">setStdModContent</a> method.
163
 
         */
164
 
        headerContent: {
165
 
            value:null
166
 
        },
167
 
 
168
 
        /**
169
 
         * @attribute footerContent
170
 
         * @type {String | Node}
171
 
         * @default undefined
172
 
         * @description The content to be added to the footer section. This will replace any existing content
173
 
         * in the footer. If you want to append, or insert new content, use the <a href="#method_setStdModContent">setStdModContent</a> method.
174
 
         */
175
 
        footerContent: {
176
 
            value:null
177
 
        },
178
 
        
179
 
        /**
180
 
         * @attribute bodyContent
181
 
         * @type {String | Node}
182
 
         * @default undefined
183
 
         * @description The content to be added to the body section. This will replace any existing content
184
 
         * in the body. If you want to append, or insert new content, use the <a href="#method_setStdModContent">setStdModContent</a> method.
185
 
         */
186
 
        bodyContent: {
187
 
            value:null
188
 
        },
189
 
        
190
 
        /**
191
 
         * @attribute fillHeight
192
 
         * @type {String}
193
 
         * @default WidgetStdMod.BODY
194
 
         * @description The section (WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER) which should be resized to fill the height of the standard module, when a 
195
 
         * height is set on the Widget. If a height is not set on the widget, then all sections are sized based on 
196
 
         * their content.
197
 
         */
198
 
        fillHeight: {
199
 
            value: StdMod.BODY,
200
 
            validator: function(val) {
201
 
                 return this._validateFillHeight(val);
202
 
            }
203
 
        }
204
 
    };
205
 
 
206
 
    /**
207
 
     * The HTML parsing rules for the WidgetStdMod class.
208
 
     * 
209
 
     * @property HTML_PARSER
210
 
     * @static
211
 
     * @type Object
212
 
     */
213
 
    StdMod.HTML_PARSER = {
214
 
        headerContent: function(contentBox) {
215
 
            return this._parseStdModHTML(STD_HEADER);
216
 
        },
217
 
 
218
 
        bodyContent: function(contentBox) {
219
 
            return this._parseStdModHTML(STD_BODY);
220
 
        },
221
 
 
222
 
        footerContent : function(contentBox) {
223
 
            return this._parseStdModHTML(STD_FOOTER);
224
 
        }
225
 
    };
226
 
 
227
 
    /**
228
 
     * Static hash of default class names used for the header,
229
 
     * body and footer sections of the standard module, keyed by
230
 
     * the section identifier (WidgetStdMod.STD_HEADER, WidgetStdMod.STD_BODY, WidgetStdMod.STD_FOOTER)
231
 
     *
232
 
     * @property SECTION_CLASS_NAMES
233
 
     * @static
234
 
     * @type Object
235
 
     */
236
 
    StdMod.SECTION_CLASS_NAMES = {
237
 
        header: Widget.getClassName(HD),
238
 
        body: Widget.getClassName(BD),
239
 
        footer: Widget.getClassName(FT)
240
 
    };
241
 
 
242
 
    /**
243
 
     * The template HTML strings for each of the standard module sections. Section entries are keyed by the section constants,
244
 
     * WidgetStdMod.HEADER, WidgetStdMod.BODY, WidgetStdMod.FOOTER, and contain the HTML to be added for each section.
245
 
     * e.g.
246
 
     * <pre>
247
 
     *    {
248
 
     *       header : '&lt;div class="yui-widget-hd"&gt;&lt;/div&gt;',
249
 
     *       body : '&lt;div class="yui-widget-bd"&gt;&lt;/div&gt;',
250
 
     *       footer : '&lt;div class="yui-widget-ft"&gt;&lt;/div&gt;'
251
 
     *    }
252
 
     * </pre>
253
 
     * @property TEMPLATES
254
 
     * @type Object
255
 
     * @static
256
 
     */
257
 
    StdMod.TEMPLATES = {
258
 
        header : '<div class="' + StdMod.SECTION_CLASS_NAMES[STD_HEADER] + '"></div>',
259
 
        body : '<div class="' + StdMod.SECTION_CLASS_NAMES[STD_BODY] + '"></div>',
260
 
        footer : '<div class="' + StdMod.SECTION_CLASS_NAMES[STD_FOOTER] + '"></div>'
261
 
    };
262
 
 
263
 
    StdMod.prototype = {
264
 
 
265
 
        /**
266
 
         * Synchronizes the UI to match the Widgets standard module state.
267
 
         * <p>
268
 
         * This method is invoked after syncUI is invoked for the Widget class
269
 
         * using YUI's aop infrastructure.
270
 
         * </p>
271
 
         * @method _syncUIStdMod
272
 
         * @protected
273
 
         */
274
 
        _syncUIStdMod : function() {
275
 
            var stdModParsed = this._stdModParsed;
276
 
 
277
 
            if (!stdModParsed || !stdModParsed[HEADER_CONTENT]) { 
278
 
                this._uiSetStdMod(STD_HEADER, this.get(HEADER_CONTENT)); 
279
 
            }
280
 
 
281
 
            if (!stdModParsed || !stdModParsed[BODY_CONTENT]) { 
282
 
                this._uiSetStdMod(STD_BODY, this.get(BODY_CONTENT));
283
 
            }
284
 
 
285
 
            if (!stdModParsed || !stdModParsed[FOOTER_CONTENT]) {
286
 
                this._uiSetStdMod(STD_FOOTER, this.get(FOOTER_CONTENT));
287
 
            }
288
 
 
289
 
            this._uiSetFillHeight(this.get(FILL_HEIGHT));
290
 
        },
291
 
 
292
 
        /**
293
 
         * Creates/Initializes the DOM for standard module support.
294
 
         * <p>
295
 
         * This method is invoked after renderUI is invoked for the Widget class
296
 
         * using YUI's aop infrastructure.
297
 
         * </p>
298
 
         * @method _renderUIStdMod
299
 
         * @protected
300
 
         */
301
 
        _renderUIStdMod : function() {
302
 
            this._stdModNode.addClass(Widget.getClassName(STDMOD));
303
 
            this._renderStdModSections();
304
 
 
305
 
            //This normally goes in bindUI but in order to allow setStdModContent() to work before renderUI
306
 
            //stage, these listeners should be set up at the earliest possible time.
307
 
            this.after(HeaderChange, this._afterHeaderChange);
308
 
            this.after(BodyChange, this._afterBodyChange);
309
 
            this.after(FooterChange, this._afterFooterChange);
310
 
        },
311
 
 
312
 
        _renderStdModSections : function() {
313
 
            if (L.isValue(this.get(HEADER_CONTENT))) { this._renderStdMod(STD_HEADER); }
314
 
            if (L.isValue(this.get(BODY_CONTENT))) { this._renderStdMod(STD_BODY); }
315
 
            if (L.isValue(this.get(FOOTER_CONTENT))) { this._renderStdMod(STD_FOOTER); }
316
 
 
317
 
 
318
 
        },
319
 
 
320
 
        /**
321
 
         * Binds event listeners responsible for updating the UI state in response to 
322
 
         * Widget standard module related state changes.
323
 
         * <p>
324
 
         * This method is invoked after bindUI is invoked for the Widget class
325
 
         * using YUI's aop infrastructure.
326
 
         * </p>
327
 
         * @method _bindUIStdMod
328
 
         * @protected
329
 
         */
330
 
        _bindUIStdMod : function() {
331
 
            // this.after(HeaderChange, this._afterHeaderChange);
332
 
            // this.after(BodyChange, this._afterBodyChange);
333
 
            // this.after(FooterChange, this._afterFooterChange);
334
 
 
335
 
            this.after(FillHeightChange, this._afterFillHeightChange);
336
 
            this.after(HeightChange, this._fillHeight);            
337
 
            this.after(ContentUpdate, this._fillHeight);
338
 
        },
339
 
 
340
 
        /**
341
 
         * Default attribute change listener for the headerContent attribute, responsible
342
 
         * for updating the UI, in response to attribute changes.
343
 
         *
344
 
         * @method _afterHeaderChange
345
 
         * @protected
346
 
         * @param {EventFacade} e The event facade for the attribute change
347
 
         */
348
 
        _afterHeaderChange : function(e) {
349
 
            if (e.src !== UI) {
350
 
                this._uiSetStdMod(STD_HEADER, e.newVal, e.stdModPosition);
351
 
            }
352
 
        },
353
 
 
354
 
        /**
355
 
         * Default attribute change listener for the bodyContent attribute, responsible
356
 
         * for updating the UI, in response to attribute changes.
357
 
         *
358
 
         * @method _afterBodyChange
359
 
         * @protected
360
 
         * @param {EventFacade} e The event facade for the attribute change
361
 
         */
362
 
        _afterBodyChange : function(e) {
363
 
            if (e.src !== UI) {
364
 
                this._uiSetStdMod(STD_BODY, e.newVal, e.stdModPosition);
365
 
            }
366
 
        },
367
 
 
368
 
        /**
369
 
         * Default attribute change listener for the footerContent attribute, responsible
370
 
         * for updating the UI, in response to attribute changes.
371
 
         *
372
 
         * @method _afterFooterChange
373
 
         * @protected
374
 
         * @param {EventFacade} e The event facade for the attribute change
375
 
         */
376
 
        _afterFooterChange : function(e) {
377
 
            if (e.src !== UI) {
378
 
                this._uiSetStdMod(STD_FOOTER, e.newVal, e.stdModPosition);
379
 
            }
380
 
        },
381
 
 
382
 
        /**
383
 
         * Default attribute change listener for the fillHeight attribute, responsible
384
 
         * for updating the UI, in response to attribute changes.
385
 
         * 
386
 
         * @method _afterFillHeightChange
387
 
         * @protected
388
 
         * @param {EventFacade} e The event facade for the attribute change
389
 
         */
390
 
        _afterFillHeightChange: function (e) {
391
 
            this._uiSetFillHeight(e.newVal);
392
 
        },
393
 
 
394
 
        /**
395
 
         * Default validator for the fillHeight attribute. Verifies that the 
396
 
         * value set is a valid section specifier - one of WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER,
397
 
         * or a falsey value if fillHeight is to be disabled.
398
 
         *
399
 
         * @method _validateFillHeight
400
 
         * @protected
401
 
         * @param {String} val The section which should be setup to fill height, or false/null to disable fillHeight
402
 
         * @return true if valid, false if not
403
 
         */
404
 
        _validateFillHeight : function(val) {
405
 
            return !val || val == StdMod.BODY || val == StdMod.HEADER || val == StdMod.FOOTER;    
406
 
        },
407
 
 
408
 
        /**
409
 
         * Updates the rendered UI, to resize the provided section so that the standard module fills out 
410
 
         * the specified widget height. Note: This method does not check whether or not a height is set 
411
 
         * on the Widget.
412
 
         * 
413
 
         * @method _uiSetFillHeight
414
 
         * @protected
415
 
         * @param {String} fillSection A valid section specifier - one of WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER
416
 
         */
417
 
        _uiSetFillHeight : function(fillSection) {
418
 
            var fillNode = this.getStdModNode(fillSection);
419
 
            var currNode = this._currFillNode;
420
 
 
421
 
            if (currNode && fillNode !== currNode){
422
 
                currNode.setStyle(HEIGHT, EMPTY);
423
 
            }
424
 
 
425
 
            if (fillNode) {
426
 
                this._currFillNode = fillNode;
427
 
            }
428
 
 
429
 
            this._fillHeight();
430
 
        },
431
 
 
432
 
        /**
433
 
         * Updates the rendered UI, to resize the current section specified by the fillHeight attribute, so
434
 
         * that the standard module fills out the Widget height. If a height has not been set on Widget,
435
 
         * the section is not resized (height is set to "auto").
436
 
         * 
437
 
         * @method _fillHeight
438
 
         * @private
439
 
         */
440
 
        _fillHeight : function() {
441
 
            if (this.get(FILL_HEIGHT)) {
442
 
                var height = this.get(HEIGHT);
443
 
                if (height != EMPTY && height != AUTO) {
444
 
                    this.fillHeight(this._currFillNode);    
445
 
                }
446
 
            }
447
 
        },
448
 
 
449
 
        /**
450
 
         * Updates the rendered UI, adding the provided content (either an HTML string, or node reference),
451
 
         * to the specified section. The content is either added before, after or replaces existing content
452
 
         * in the section, based on the value of the <code>where</code> argument.
453
 
         * 
454
 
         * @method _uiSetStdMod
455
 
         * @protected
456
 
         * 
457
 
         * @param {String} section The section to be updated. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER. 
458
 
         * @param {String | Node} content The new content (either as an HTML string, or Node reference) to add to the section
459
 
         * @param {String} where Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE.
460
 
         * If not provided, the content will replace existing content in the section.
461
 
         */
462
 
        _uiSetStdMod : function(section, content, where) {
463
 
            // Using isValue, so that "" is valid content 
464
 
            if (L.isValue(content)) {
465
 
                var node = this.getStdModNode(section) || this._renderStdMod(section);
466
 
 
467
 
                this._addStdModContent(node, content, where);
468
 
 
469
 
                this.set(section + CONTENT_SUFFIX, this._getStdModContent(section), {src:UI});
470
 
            } else {
471
 
                this._eraseStdMod(section);
472
 
            }
473
 
            this.fire(ContentUpdate);
474
 
        },
475
 
 
476
 
        /**
477
 
         * Creates the DOM node for the given section, and inserts it into the correct location in the contentBox.
478
 
         *
479
 
         * @method _renderStdMod
480
 
         * @protected
481
 
         * @param {String} section The section to create/render. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
482
 
         * @return {Node} A reference to the added section node
483
 
         */
484
 
        _renderStdMod : function(section) {
485
 
 
486
 
            var contentBox = this.get(CONTENT_BOX),
487
 
                sectionNode = this._findStdModSection(section);
488
 
 
489
 
            if (!sectionNode) {
490
 
                sectionNode = this._getStdModTemplate(section);
491
 
            }
492
 
 
493
 
            this._insertStdModSection(contentBox, section, sectionNode);
494
 
 
495
 
            this[section + NODE_SUFFIX] = sectionNode;
496
 
            return this[section + NODE_SUFFIX];
497
 
        },
498
 
 
499
 
        /**
500
 
         * Removes the DOM node for the given section.
501
 
         *
502
 
         * @method _eraseStdMod
503
 
         * @protected
504
 
         * @param {String} section The section to remove. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
505
 
         */
506
 
        _eraseStdMod : function(section) {
507
 
            var sectionNode = this.getStdModNode(section);
508
 
            if (sectionNode) {
509
 
                sectionNode.remove(true);
510
 
                delete this[section + NODE_SUFFIX];
511
 
            }
512
 
        },
513
 
 
514
 
        /**
515
 
         * Helper method to insert the Node for the given section into the correct location in the contentBox.
516
 
         *
517
 
         * @method _insertStdModSection
518
 
         * @private
519
 
         * @param {Node} contentBox A reference to the Widgets content box.
520
 
         * @param {String} section The section to create/render. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
521
 
         * @param {Node} sectionNode The Node for the section.
522
 
         */
523
 
        _insertStdModSection : function(contentBox, section, sectionNode) {
524
 
            var fc = contentBox.get(FIRST_CHILD);
525
 
 
526
 
            if (section === STD_FOOTER || !fc) {
527
 
                contentBox.appendChild(sectionNode);
528
 
            } else {
529
 
                if (section === STD_HEADER) {
530
 
                    contentBox.insertBefore(sectionNode, fc);
531
 
                } else {
532
 
                    var footer = this[STD_FOOTER + NODE_SUFFIX];
533
 
                    if (footer) {
534
 
                        contentBox.insertBefore(sectionNode, footer);
535
 
                    } else {
536
 
                        contentBox.appendChild(sectionNode);
537
 
                    }
538
 
                }
539
 
            }
540
 
        },
541
 
 
542
 
        /**
543
 
         * Gets a new Node reference for the given standard module section, by cloning
544
 
         * the stored template node.
545
 
         *
546
 
         * @method _getStdModTemplate
547
 
         * @protected
548
 
         * @param {String} section The section to create a new node for. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
549
 
         * @return {Node} The new Node instance for the section
550
 
         */
551
 
        _getStdModTemplate : function(section) {
552
 
            return Node.create(StdMod.TEMPLATES[section], this._stdModNode.get(OWNER_DOCUMENT));
553
 
        },
554
 
 
555
 
        /**
556
 
         * Helper method to add content to a StdMod section node.
557
 
         * The content is added either before, after or replaces the existing node content 
558
 
         * based on the value of the <code>where</code> argument.
559
 
         * 
560
 
         * @method _addStdModContent
561
 
         * @private
562
 
         * 
563
 
         * @param {Node} node The section Node to be updated.
564
 
         * @param {Node|NodeList|String} children The new content Node, NodeList or String to be added to section Node provided.
565
 
         * @param {String} where Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE.
566
 
         * If not provided, the content will replace existing content in the Node.
567
 
         */
568
 
        _addStdModContent : function(node, children, where) {
569
 
 
570
 
            // StdMod where to Node where
571
 
            switch (where) {
572
 
                case StdMod.BEFORE:  // 0 is before fistChild
573
 
                    where = 0;
574
 
                    break;
575
 
                case StdMod.AFTER:   // undefined is appendChild
576
 
                    where = undefined;
577
 
                    break;
578
 
                default:            // replace is replace, not specified is replace
579
 
                    where = StdMod.REPLACE; 
580
 
            }
581
 
 
582
 
            node.insert(children, where);
583
 
        },
584
 
 
585
 
        /**
586
 
         * Helper method to obtain the precise height of the node provided, including padding and border.
587
 
         * The height could be a sub-pixel value for certain browsers, such as Firefox 3.
588
 
         *
589
 
         * @method _getPreciseHeight
590
 
         * @private
591
 
         * @param {Node} node The node for which the precise height is required.
592
 
         * @return {Number} The height of the Node including borders and padding, possibly a float.
593
 
         */
594
 
        _getPreciseHeight : function(node) {
595
 
            var height = (node) ? node.get(OFFSET_HEIGHT) : 0,
596
 
                getBCR = "getBoundingClientRect";
597
 
 
598
 
            if (node && node.hasMethod(getBCR)) {
599
 
                var preciseRegion = node.invoke(getBCR);
600
 
                if (preciseRegion) {
601
 
                    height = preciseRegion.bottom - preciseRegion.top;
602
 
                }
603
 
            }
604
 
 
605
 
            return height;
606
 
        },
607
 
 
608
 
        /**
609
 
         * Helper method to to find the rendered node for the given section,
610
 
         * if it exists.
611
 
         * 
612
 
         * @method _findStdModSection
613
 
         * @private
614
 
         * @param {String} section The section for which the render Node is to be found. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
615
 
         * @return {Node} The rendered node for the given section, or null if not found.
616
 
         */
617
 
        _findStdModSection: function(section) {
618
 
            return this.get(CONTENT_BOX).one("> ." + StdMod.SECTION_CLASS_NAMES[section]);
619
 
        },
620
 
 
621
 
        /**
622
 
         * Utility method, used by WidgetStdMods HTML_PARSER implementation
623
 
         * to extract data for each section from markup.
624
 
         *
625
 
         * @method _parseStdModHTML
626
 
         * @private
627
 
         * @param {String} section
628
 
         * @return {String} Inner HTML string with the contents of the section
629
 
         */
630
 
        _parseStdModHTML : function(section) {
631
 
 
632
 
            var node = this._findStdModSection(section);
633
 
 
634
 
            if (node) {
635
 
                if (!this._stdModParsed) {
636
 
                    this._stdModParsed = {};
637
 
                    Y.before(this._applyStdModParsedConfig, this, APPLY_PARSED_CONFIG);
638
 
                }
639
 
                this._stdModParsed[section + CONTENT_SUFFIX] = 1;
640
 
 
641
 
                return node.get("innerHTML");
642
 
            }
643
 
 
644
 
            return null;
645
 
        },
646
 
 
647
 
        /**
648
 
         * This method is injected before the _applyParsedConfig step in 
649
 
         * the application of HTML_PARSER, and sets up the state to 
650
 
         * identify whether or not we should remove the current DOM content
651
 
         * or not, based on whether or not the current content attribute value
652
 
         * was extracted from the DOM, or provided by the user configuration
653
 
         * 
654
 
         * @method _applyStdModParsedConfig
655
 
         * @private
656
 
         */
657
 
        _applyStdModParsedConfig : function(node, cfg, parsedCfg) {
658
 
            var parsed = this._stdModParsed; 
659
 
            if (parsed) {
660
 
                parsed[HEADER_CONTENT] = !(HEADER_CONTENT in cfg) && (HEADER_CONTENT in parsed);
661
 
                parsed[BODY_CONTENT] = !(BODY_CONTENT in cfg) && (BODY_CONTENT in parsed);
662
 
                parsed[FOOTER_CONTENT] = !(FOOTER_CONTENT in cfg) && (FOOTER_CONTENT in parsed);
663
 
            }
664
 
        },
665
 
 
666
 
        /**
667
 
         * Retrieves the child nodes (content) of a standard module section
668
 
         * 
669
 
         * @method _getStdModContent
670
 
         * @private
671
 
         * @param {String} section The standard module section whose child nodes are to be retrieved. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
672
 
         * @return {Node} The child node collection of the standard module section.
673
 
         */
674
 
        _getStdModContent : function(section) {
675
 
            return (this[section + NODE_SUFFIX]) ? this[section + NODE_SUFFIX].get(CHILD_NODES) : null;
676
 
        },
677
 
 
678
 
        /**
679
 
         * Updates the body section of the standard module with the content provided (either an HTML string, or node reference).
680
 
         * <p>
681
 
         * This method can be used instead of the corresponding section content attribute if you'd like to retain the current content of the section,
682
 
         * and insert content before or after it, by specifying the <code>where</code> argument.
683
 
         * </p>
684
 
         * @method setStdModContent
685
 
         * @param {String} section The standard module section whose content is to be updated. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
686
 
         * @param {String | Node} content The content to be added, either an HTML string or a Node reference.
687
 
         * @param {String} where Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE.
688
 
         * If not provided, the content will replace existing content in the section.
689
 
         */
690
 
        setStdModContent : function(section, content, where) {
691
 
            //var node = this.getStdModNode(section) || this._renderStdMod(section);
692
 
            this.set(section + CONTENT_SUFFIX, content, {stdModPosition:where});
693
 
            //this._addStdModContent(node, content, where);
694
 
        },
695
 
 
696
 
        /**
697
 
         * Returns the node reference for the given section. Note: The DOM is not queried for the node reference. The reference
698
 
         * stored by the widget instance is returned if set.
699
 
         * 
700
 
         * @method getStdModNode
701
 
         * @param {String} section The section whose node reference is required. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
702
 
         * @return {Node} The node reference for the section, or null if not set.
703
 
         */
704
 
        getStdModNode : function(section) {
705
 
            return this[section + NODE_SUFFIX] || null;
706
 
        },
707
 
 
708
 
        /**
709
 
         * Sets the height on the provided header, body or footer element to 
710
 
         * fill out the height of the Widget. It determines the height of the 
711
 
         * widgets bounding box, based on it's configured height value, and 
712
 
         * sets the height of the provided section to fill out any 
713
 
         * space remaining after the other standard module section heights 
714
 
         * have been accounted for.
715
 
         * 
716
 
         * <p><strong>NOTE:</strong> This method is not designed to work if an explicit 
717
 
         * height has not been set on the Widget, since for an "auto" height Widget, 
718
 
         * the heights of the header/body/footer will drive the height of the Widget.</p>
719
 
         *
720
 
         * @method fillHeight
721
 
         * @param {Node} node The node which should be resized to fill out the height
722
 
         * of the Widget bounding box. Should be a standard module section node which belongs
723
 
         * to the widget.
724
 
         */
725
 
        fillHeight : function(node) {
726
 
            if (node) {
727
 
                var contentBox = this.get(CONTENT_BOX),
728
 
                    stdModNodes = [this.headerNode, this.bodyNode, this.footerNode],
729
 
                    stdModNode,
730
 
                    cbContentHeight,
731
 
                    filled = 0,
732
 
                    remaining = 0,
733
 
 
734
 
                    validNode = false;
735
 
 
736
 
                for (var i = 0, l = stdModNodes.length; i < l; i++) {
737
 
                    stdModNode = stdModNodes[i];
738
 
                    if (stdModNode) {
739
 
                        if (stdModNode !== node) {
740
 
                            filled += this._getPreciseHeight(stdModNode);
741
 
                        } else {
742
 
                            validNode = true;
743
 
                        }
744
 
                    }
745
 
                }
746
 
 
747
 
                if (validNode) {
748
 
                    if (UA.ie || UA.opera) {
749
 
                        // Need to set height to 0, to allow height to be reduced
750
 
                        node.set(OFFSET_HEIGHT, 0);
751
 
                    }
752
 
 
753
 
                    cbContentHeight = contentBox.get(OFFSET_HEIGHT) -
754
 
                            parseInt(contentBox.getComputedStyle("paddingTop"), 10) - 
755
 
                            parseInt(contentBox.getComputedStyle("paddingBottom"), 10) - 
756
 
                            parseInt(contentBox.getComputedStyle("borderBottomWidth"), 10) - 
757
 
                            parseInt(contentBox.getComputedStyle("borderTopWidth"), 10);
758
 
 
759
 
                    if (L.isNumber(cbContentHeight)) {
760
 
                        remaining = cbContentHeight - filled;
761
 
                        if (remaining >= 0) {
762
 
                            node.set(OFFSET_HEIGHT, remaining);
763
 
                        }
764
 
                    }
765
 
                }
766
 
            }
767
 
        }
768
 
    };
769
 
 
770
 
    Y.WidgetStdMod = StdMod;
771
 
 
772
 
 
773
 
}, '3.4.1' ,{requires:['base-build', 'widget']});