Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / source / BoundList.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5   <title>The source code</title>
6   <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7   <script type="text/javascript" src="../prettify/prettify.js"></script>
8   <style type="text/css">
9     .highlight { display: block; background-color: #ddd; }
10   </style>
11   <script type="text/javascript">
12     function highlight() {
13       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
14     }
15   </script>
16 </head>
17 <body onload="prettyPrint(); highlight();">
18   <pre class="prettyprint lang-js"><span id='Ext-layout-component-BoundList'>/**
19 </span> * Component layout for {@link Ext.view.BoundList}. Handles constraining the height to the configured maxHeight.
20  * @class Ext.layout.component.BoundList
21  * @extends Ext.layout.component.Component
22  * @private
23  */
24 Ext.define('Ext.layout.component.BoundList', {
25     extend: 'Ext.layout.component.Component',
26     alias: 'layout.boundlist',
27
28     type: 'component',
29
30     beforeLayout: function() {
31         return this.callParent(arguments) || this.owner.refreshed &gt; 0;
32     },
33
34     onLayout : function(width, height) {
35         var me = this,
36             owner = me.owner,
37             floating = owner.floating,
38             el = owner.el,
39             xy = el.getXY(),
40             isNumber = Ext.isNumber,
41             minWidth, maxWidth, minHeight, maxHeight,
42             naturalWidth, naturalHeight, constrainedWidth, constrainedHeight, undef;
43
44         if (floating) {
45             // Position offscreen so the natural width is not affected by the viewport's right edge
46             el.setXY([-9999,-9999]);
47         }
48
49         // Calculate initial layout
50         me.setTargetSize(width, height);
51
52         // Handle min/maxWidth for auto-width
53         if (!isNumber(width)) {
54             minWidth = owner.minWidth;
55             maxWidth = owner.maxWidth;
56             if (isNumber(minWidth) || isNumber(maxWidth)) {
57                 naturalWidth = el.getWidth();
58                 if (naturalWidth &lt; minWidth) {
59                     constrainedWidth = minWidth;
60                 }
61                 else if (naturalWidth &gt; maxWidth) {
62                     constrainedWidth = maxWidth;
63                 }
64                 if (constrainedWidth) {
65                     me.setTargetSize(constrainedWidth);
66                 }
67             }
68         }
69         // Handle min/maxHeight for auto-height
70         if (!isNumber(height)) {
71             minHeight = owner.minHeight;
72             maxHeight = owner.maxHeight;
73             if (isNumber(minHeight) || isNumber(maxHeight)) {
74                 naturalHeight = el.getHeight();
75                 if (naturalHeight &lt; minHeight) {
76                     constrainedHeight = minHeight;
77                 }
78                 else if (naturalHeight &gt; maxHeight) {
79                     constrainedHeight = maxHeight;
80                 }
81                 if (constrainedHeight) {
82                     me.setTargetSize(undef, constrainedHeight);
83                 }
84             }
85         }
86
87         if (floating) {
88             // Restore position
89             el.setXY(xy);
90         }
91     },
92
93     afterLayout: function() {
94         var me = this,
95             toolbar = me.owner.pagingToolbar;
96         me.callParent();
97         if (toolbar) {
98             toolbar.doComponentLayout();
99         }
100     },
101
102     setTargetSize : function(width, height) {
103         var me = this,
104             owner = me.owner,
105             listHeight = null,
106             toolbar;
107
108         // Size the listEl
109         if (Ext.isNumber(height)) {
110             listHeight = height - owner.el.getFrameWidth('tb');
111             toolbar = owner.pagingToolbar;
112             if (toolbar) {
113                 listHeight -= toolbar.getHeight();
114             }
115         }
116         me.setElementSize(owner.listEl, null, listHeight);
117
118         me.callParent(arguments);
119     }
120
121 });
122 </pre>
123 </body>
124 </html>