13693261870
2022-09-16 354b3dbfbffb3df45212a2a44dbbf48b4acc2594
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js"><span id='Ext-layout-container-Container'>/**
</span> * This class is intended to be extended or created via the {@link Ext.container.Container#layout layout}
 * configuration property.  See {@link Ext.container.Container#layout} for additional details.
 */
Ext.define('Ext.layout.container.Container', {
 
    /* Begin Definitions */
 
    alias: ['layout.container'],
 
    extend: 'Ext.layout.Layout',
 
    alternateClassName: 'Ext.layout.ContainerLayout',
 
    mixins: {
        elementCt: 'Ext.util.ElementContainer'
    },
 
    requires: [
        'Ext.XTemplate'
    ],
 
<span id='Ext-layout-container-Container-property-type'>    type: 'container',
</span>
    /* End Definitions */
 
<span id='Ext-layout-container-Container-cfg-itemCls'>    /**
</span>     * @cfg {String} itemCls
     * An optional extra CSS class that will be added to the container. This can be useful for
     * adding customized styles to the container or any of its children using standard CSS
     * rules. See {@link Ext.Component}.{@link Ext.Component#componentCls componentCls} also.
     */
 
<span id='Ext-layout-container-Container-method-beginCollapse'>    /**
</span>     * @private
     * Called by an owning Panel before the Panel begins its collapse process.
     * Most layouts will not need to override the default Ext.emptyFn implementation.
     */
    beginCollapse: Ext.emptyFn,
 
<span id='Ext-layout-container-Container-method-beginExpand'>    /**
</span>     * @private
     * Called by an owning Panel before the Panel begins its expand process.
     * Most layouts will not need to override the default Ext.emptyFn implementation.
     */
    beginExpand: Ext.emptyFn,
 
<span id='Ext-layout-container-Container-property-animatePolicy'>    /**
</span>     * An object which contains boolean properties specifying which properties are to be 
     * animated upon flush of child Component ContextItems. For example, Accordion would
     * have:
     *
     *      {
     *          y: true,
     *          height: true
     *      }
     *
     * @private
     */
    animatePolicy: null,
 
<span id='Ext-layout-container-Container-property-childEls'>    childEls: [
</span><span id='Ext-layout-container-Container-property-overflowPadderEl'>        /**
</span>         * @property {Ext.Element} overflowPadderEl
         * The element used to correct body padding during overflow.
         */
        'overflowPadderEl'
    ],
 
<span id='Ext-layout-container-Container-property-renderTpl'>    renderTpl: [
</span>        '{%this.renderBody(out,values)%}'
    ],
 
<span id='Ext-layout-container-Container-property-usesContainerHeight'>    usesContainerHeight: true,
</span><span id='Ext-layout-container-Container-property-usesContainerWidth'>    usesContainerWidth: true,
</span><span id='Ext-layout-container-Container-property-usesHeight'>    usesHeight: true,
</span><span id='Ext-layout-container-Container-property-usesWidth'>    usesWidth: true,
</span>
<span id='Ext-layout-container-Container-method-constructor'>    constructor: function () {
</span>        this.callParent(arguments);
        this.mixins.elementCt.constructor.call(this);
    },
 
<span id='Ext-layout-container-Container-method-destroy'>    destroy : function() {
</span>        this.callParent();
        this.mixins.elementCt.destroy.call(this);
    },
 
<span id='Ext-layout-container-Container-method-beginLayout'>    /**
</span>     * In addition to work done by our base classes, containers benefit from some extra
     * cached data. The following properties are added to the ownerContext:
     * 
     *  - visibleItems: the result of {@link #getVisibleItems}
     *  - childItems: the ContextItem[] for each visible item
     *  - targetContext: the ContextItem for the {@link #getTarget} element
     */
    beginLayout: function (ownerContext) {
        this.callParent(arguments);
 
        ownerContext.targetContext = ownerContext.paddingContext = ownerContext.getEl('getTarget', this);
 
        this.cacheChildItems(ownerContext);
    },
 
<span id='Ext-layout-container-Container-method-beginLayoutCycle'>    beginLayoutCycle: function (ownerContext, firstCycle) {
</span>        var me = this;
 
        me.callParent(arguments);
 
        if (firstCycle) {
            if (me.usesContainerHeight) {
                ++ownerContext.consumersContainerHeight;
            }
            if (me.usesContainerWidth) {
                ++ownerContext.consumersContainerWidth;
            }
        }
    },
 
<span id='Ext-layout-container-Container-method-cacheChildItems'>    cacheChildItems: function (ownerContext) {
</span>        var context = ownerContext.context,
            childItems = [],
            items = this.getVisibleItems(),
            length = items.length,
            i;
 
        ownerContext.childItems = childItems;
        ownerContext.visibleItems = items;
 
        for (i = 0; i &lt; length; ++i) {
            childItems.push(context.getCmp(items[i]));
        }
    },
 
<span id='Ext-layout-container-Container-method-cacheElements'>    cacheElements: function () {
</span>        var owner = this.owner;
 
        this.applyChildEls(owner.el, owner.id); // from ElementContainer mixin
    },
 
<span id='Ext-layout-container-Container-method-configureItem'>    /**
</span>     * Adds layout's itemCls and owning Container's itemCls
     * @protected
     */
    configureItem: function(item) {
        var me = this,
            itemCls = me.itemCls,
            ownerItemCls = me.owner.itemCls,
            addClasses;
 
        // Effectively callParent but without the function overhead
        item.ownerLayout = me;
 
        if (itemCls) {
            // itemCls can be a single clas or an array
            addClasses = typeof itemCls === 'string' ? [itemCls] : itemCls;
        }
        if (ownerItemCls) {
            addClasses = Ext.Array.push(addClasses||[], ownerItemCls);
        }
        if (addClasses) {
            item.addCls(addClasses);
        }
    },
 
<span id='Ext-layout-container-Container-method-doRenderBody'>    doRenderBody: function (out, renderData) {
</span>        // Careful! This method is bolted on to the renderTpl so all we get for context is
        // the renderData! The &quot;this&quot; pointer is the renderTpl instance!
 
        this.renderItems(out, renderData);
        this.renderContent(out, renderData);
    },
 
<span id='Ext-layout-container-Container-method-doRenderContainer'>    doRenderContainer: function (out, renderData) {
</span>        // Careful! This method is bolted on to the renderTpl so all we get for context is
        // the renderData! The &quot;this&quot; pointer is the renderTpl instance!
 
        var me = renderData.$comp.layout,
            tpl = me.getRenderTpl(),
            data = me.getRenderData();
 
        tpl.applyOut(data, out);
    },
 
<span id='Ext-layout-container-Container-method-doRenderItems'>    doRenderItems: function (out, renderData) {
</span>        // Careful! This method is bolted on to the renderTpl so all we get for context is
        // the renderData! The &quot;this&quot; pointer is the renderTpl instance!
 
        var me = renderData.$layout,
            tree = me.getRenderTree();
 
        if (tree) {
            Ext.DomHelper.generateMarkup(tree, out);
        }
    },
 
<span id='Ext-layout-container-Container-method-finishRender'>    finishRender: function () {
</span>        var me = this,
            target, items;
 
        me.callParent();
 
        me.cacheElements();
 
        target = me.getRenderTarget();
        items = me.getLayoutItems();
 
        //&lt;debug&gt;
        if (me.targetCls &amp;&amp; !me.getTarget().hasCls(me.targetCls)) {
            Ext.log.warn('targetCls is missing. This may mean that getTargetEl() is being overridden but not applyTargetCls(). ' + me.owner.id);
        }
        //&lt;/debug&gt;
 
        me.finishRenderItems(target, items);
    },
 
<span id='Ext-layout-container-Container-method-notifyOwner'>    /**
</span>     * @private
     * Called for every layout in the layout context after all the layouts have been finally flushed
     */
    notifyOwner: function() {
        this.owner.afterLayout(this);
    },
 
<span id='Ext-layout-container-Container-method-getContainerSize'>    /**
</span>     * Returns the container size (that of the target). Only the fixed-sized dimensions can
     * be returned because the shrinkWrap dimensions are based on the contentWidth/Height
     * as determined by the container layout.
     *
     * @param {Ext.layout.ContextItem} ownerContext The owner's context item.
     * @param {Boolean} [inDom=false] True if the container size must be in the DOM.
     * @return {Object} The size
     * @return {Number} return.width The width
     * @return {Number} return.height The height
     * @protected
     */
    getContainerSize : function(ownerContext, inDom) {
        // Subtle But Important:
        // 
        // We don't want to call getProp/hasProp et.al. unless we in fact need that value
        // for our results! If we call it and don't need it, the layout manager will think
        // we depend on it and will schedule us again should it change.
 
        var targetContext = ownerContext.targetContext,
            frameInfo = targetContext.getFrameInfo(),
            padding = ownerContext.paddingContext.getPaddingInfo(),
            got = 0,
            needed = 0,
            gotWidth, gotHeight, width, height;
 
        // In an shrinkWrap width/height case, we must not ask for any of these dimensions
        // because they will be determined by contentWidth/Height which is calculated by
        // this layout...
 
        // Fit/Card layouts are able to set just the width of children, allowing child's
        // resulting height to autosize the Container.
        // See examples/tabs/tabs.html for an example of this.
 
        if (!ownerContext.widthModel.shrinkWrap) {
            ++needed;
            width = inDom ? targetContext.getDomProp('width') : targetContext.getProp('width');
            gotWidth = (typeof width == 'number');
            if (gotWidth) {
                ++got;
                width -= frameInfo.width + padding.width;
                if (width &lt; 0) {
                    width = 0;
                }
            }
        }
 
        if (!ownerContext.heightModel.shrinkWrap) {
            ++needed;
            height = inDom ? targetContext.getDomProp('height') : targetContext.getProp('height');
            gotHeight = (typeof height == 'number');
            if (gotHeight) {
                ++got;
                height -= frameInfo.height + padding.height;
                if (height &lt; 0) {
                    height = 0;
                }
            }
        }
 
        return {
            width: width,
            height: height,
            needed: needed,
            got: got,
            gotAll: got == needed,
            gotWidth: gotWidth,
            gotHeight: gotHeight
        };
    },
    
<span id='Ext-layout-container-Container-method-getPositionOffset'>    // This method is used to offset the DOM position when checking
</span>    // whether the element is a certain child of the target. This is
    // required in cases where the extra elements prepended to the target
    // before any of the items. An example of this is when using labelAlign: 'top'
    // on a field. The label appears first in the DOM before any child items are
    // created, so when we check the position we need to add an extra offset.
    // Containers that create an innerCt are exempt because this new element
    // preserves the order
    getPositionOffset: function(position) {
        if (!this.createsInnerCt) {
            var offset = this.owner.itemNodeOffset;
            if (offset) {
                position += offset;
            }
        }
        return position;
    },
 
<span id='Ext-layout-container-Container-method-getLayoutItems'>    /**
</span>     * Returns an array of child components either for a render phase (Performed in the beforeLayout
     * method of the layout's base class), or the layout phase (onLayout).
     * @return {Ext.Component[]} of child components
     */
    getLayoutItems: function() {
        var owner = this.owner,
            items = owner &amp;&amp; owner.items;
 
        return (items &amp;&amp; items.items) || [];
    },
 
<span id='Ext-layout-container-Container-method-getRenderData'>    getRenderData: function () {
</span>        var comp = this.owner;
 
        return {
            $comp: comp,
            $layout: this,
            ownerId: comp.id
        };
    },
 
<span id='Ext-layout-container-Container-method-getRenderedItems'>    /**
</span>     * @protected
     * Returns all items that are rendered
     * @return {Array} All matching items
     */
    getRenderedItems: function() {
        var me = this,
            target = me.getRenderTarget(),
            items = me.getLayoutItems(),
            ln = items.length,
            renderedItems = [],
            i, item;
 
        for (i = 0; i &lt; ln; i++) {
            item = items[i];
            if (item.rendered &amp;&amp; me.isValidParent(item, target, i)) {
                renderedItems.push(item);
            }
        }
 
        return renderedItems;
    },
 
<span id='Ext-layout-container-Container-method-getRenderTarget'>    /**
</span>     * Returns the element into which rendering must take place. Defaults to the owner Container's
     * target element.
     *
     * May be overridden in layout managers which implement an inner element.
     *
     * @return {Ext.Element}
     */
    getRenderTarget: function() {
        return this.owner.getTargetEl();
    },
 
<span id='Ext-layout-container-Container-method-getElementTarget'>    /**
</span>     * Returns the element into which extra functional DOM elements can be inserted. Defaults to the owner Component's encapsulating element.
     *
     * May be overridden in Component layout managers which implement a {@link #getRenderTarget component render target} which must only
     * contain child components.
     * @return {Ext.Element}
     */
    getElementTarget: function() {
        return this.getRenderTarget();
    },
 
<span id='Ext-layout-container-Container-method-getRenderTpl'>    getRenderTpl: function () {
</span>        var me = this,
            renderTpl = Ext.XTemplate.getTpl(this, 'renderTpl');
 
        // Make sure all standard callout methods for the owner component are placed on the
        // XTemplate instance (but only once please):
        if (!renderTpl.renderContent) {
            me.owner.setupRenderTpl(renderTpl);
        }
 
        return renderTpl;
    },
 
<span id='Ext-layout-container-Container-method-getRenderTree'>    getRenderTree: function () {
</span>        var result,
            items = this.owner.items,
            itemsGen,
            renderCfgs = {};
        
        do {
            itemsGen = items.generation;
            result = this.getItemsRenderTree(this.getLayoutItems(), renderCfgs);
        } while (items.generation !== itemsGen);
        return result;
    },
    
<span id='Ext-layout-container-Container-method-renderChildren'>    renderChildren: function () {
</span>        var me = this,
            ownerItems = me.owner.items,
            target = me.getRenderTarget(),
            itemsGen, items;
            
        // During the render phase, new items may be added. Specifically, a panel will
        // create a placeholder component during render if required, so we need to catch
        // it here so we can render it.
        do {
            itemsGen = ownerItems.generation;
            items = me.getLayoutItems();
            me.renderItems(items, target);
        } while (ownerItems.generation !== itemsGen);
    },
 
<span id='Ext-layout-container-Container-method-getScrollbarsNeeded'>    getScrollbarsNeeded: function (width, height, contentWidth, contentHeight) {
</span>        var scrollbarSize = Ext.getScrollbarSize(),
            hasWidth = typeof width == 'number',
            hasHeight = typeof height == 'number',
            needHorz = 0,
            needVert = 0;
 
        // No space-consuming scrollbars.
        if (!scrollbarSize.width) {
            return 0;
        }
        if (hasHeight &amp;&amp; height &lt; contentHeight) {
            needVert = 2;
            width -= scrollbarSize.width;
        }
 
        if (hasWidth &amp;&amp; width &lt; contentWidth) {
            needHorz = 1;
            if (!needVert &amp;&amp; hasHeight) {
                height -= scrollbarSize.height;
                if (height &lt; contentHeight) {
                    needVert = 2;
                }
            }
        }
 
        return needVert + needHorz;
    },
 
<span id='Ext-layout-container-Container-method-getTarget'>    /**
</span>     * Returns the owner component's resize element.
     * @return {Ext.Element}
     */
    getTarget: function() {
        return this.owner.getTargetEl();
    },
 
<span id='Ext-layout-container-Container-method-getVisibleItems'>    /**
</span>     * @protected
     * Returns all items that are both rendered and visible
     * @return {Array} All matching items
     */
    getVisibleItems: function() {
        var target   = this.getRenderTarget(),
            items = this.getLayoutItems(),
            ln = items.length,
            visibleItems = [],
            i, item;
 
        for (i = 0; i &lt; ln; i++) {
            item = items[i];
            if (item.rendered &amp;&amp; this.isValidParent(item, target, i) &amp;&amp; item.hidden !== true) {
                visibleItems.push(item);
            }
        }
 
        return visibleItems;
    },
 
<span id='Ext-layout-container-Container-method-setupRenderTpl'>    setupRenderTpl: function (renderTpl) {
</span>        var me = this;
 
        renderTpl.renderBody = me.doRenderBody;
        renderTpl.renderContainer = me.doRenderContainer;
        renderTpl.renderItems = me.doRenderItems;
    },
    
<span id='Ext-layout-container-Container-method-getContentTarget'>    getContentTarget: function(){
</span>        return this.owner.getDefaultContentTarget();
    }
 
});
</pre>
</body>
</html>