Border.html
30.8 KB
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
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
<!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-Border'>/**
</span> * This is a multi-pane, application-oriented UI layout style that supports multiple nested panels, automatic bars
* between regions and built-in {@link Ext.panel.Panel#collapsible expanding and collapsing} of regions.
*
* This class is intended to be extended or created via the `layout:'border'` {@link Ext.container.Container#layout}
* config, and should generally not need to be created directly via the new keyword.
*
* @example
* Ext.create('Ext.panel.Panel', {
* width: 500,
* height: 300,
* title: 'Border Layout',
* layout: 'border',
* items: [{
* title: 'South Region is resizable',
* region: 'south', // position for region
* xtype: 'panel',
* height: 100,
* split: true, // enable resizing
* margins: '0 5 5 5'
* },{
* // xtype: 'panel' implied by default
* title: 'West Region is collapsible',
* region:'west',
* xtype: 'panel',
* margins: '5 0 0 5',
* width: 200,
* collapsible: true, // make collapsible
* id: 'west-region-container',
* layout: 'fit'
* },{
* title: 'Center Region',
* region: 'center', // center region is required, no width/height specified
* xtype: 'panel',
* layout: 'fit',
* margins: '5 5 0 0'
* }],
* renderTo: Ext.getBody()
* });
*
* # Notes
*
* - When using the split option, the layout will automatically insert a {@link Ext.resizer.Splitter}
* into the appropriate place. This will modify the underlying
* {@link Ext.container.Container#property-items items} collection in the container.
*
* - Any Container using the Border layout **must** have a child item with `region:'center'`.
* The child item in the center region will always be resized to fill the remaining space
* not used by the other regions in the layout.
*
* - Any child items with a region of `west` or `east` may be configured with either an initial
* `width`, or a {@link Ext.layout.container.Box#flex} value, or an initial percentage width
* **string** (Which is simply divided by 100 and used as a flex value).
* The 'center' region has a flex value of `1`.
*
* - Any child items with a region of `north` or `south` may be configured with either an initial
* `height`, or a {@link Ext.layout.container.Box#flex} value, or an initial percentage height
* **string** (Which is simply divided by 100 and used as a flex value).
* The 'center' region has a flex value of `1`.
*
* - **There is no BorderLayout.Region class in ExtJS 4.0+**
*/
Ext.define('Ext.layout.container.Border', {
alias: 'layout.border',
extend: 'Ext.layout.container.Container',
requires: ['Ext.resizer.BorderSplitter', 'Ext.Component', 'Ext.fx.Anim'],
alternateClassName: 'Ext.layout.BorderLayout',
targetCls: Ext.baseCSSPrefix + 'border-layout-ct',
itemCls: [Ext.baseCSSPrefix + 'border-item', Ext.baseCSSPrefix + 'box-item'],
type: 'border',
<span id='Ext-layout-container-Border-cfg-split'> /**
</span> * @cfg {Boolean} split
* This configuration option is to be applied to the **child `items`** managed by this layout.
* Each region with `split:true` will get a {@link Ext.resizer.BorderSplitter Splitter} that
* allows for manual resizing of the container. Except for the `center` region.
*/
<span id='Ext-layout-container-Border-cfg-splitterResize'> /**
</span> * @cfg {Boolean} [splitterResize=true]
* This configuration option is to be applied to the **child `items`** managed by this layout and
* is used in conjunction with {@link #split}. By default, when specifying {@link #split}, the region
* can be dragged to be resized. Set this option to false to show the split bar but prevent resizing.
*/
<span id='Ext-layout-container-Border-cfg-padding'> /**
</span> * @cfg {Number/String/Object} padding
* Sets the padding to be applied to all child items managed by this layout.
*
* This property can be specified as a string containing space-separated, numeric
* padding values. The order of the sides associated with each value matches the way
* CSS processes padding values:
*
* - If there is only one value, it applies to all sides.
* - If there are two values, the top and bottom borders are set to the first value
* and the right and left are set to the second.
* - If there are three values, the top is set to the first value, the left and right
* are set to the second, and the bottom is set to the third.
* - If there are four values, they apply to the top, right, bottom, and left,
* respectively.
*
*/
padding: undefined,
percentageRe: /(\d+)%/,
<span id='Ext-layout-container-Border-property-axisProps'> /**
</span> * Reused meta-data objects that describe axis properties.
* @private
*/
axisProps: {
horz: {
borderBegin: 'west',
borderEnd: 'east',
horizontal: true,
posProp: 'x',
sizeProp: 'width',
sizePropCap: 'Width'
},
vert: {
borderBegin: 'north',
borderEnd: 'south',
horizontal: false,
posProp: 'y',
sizeProp: 'height',
sizePropCap: 'Height'
}
},
// @private
centerRegion: null,
<span id='Ext-layout-container-Border-property-collapseDirections'> /**
</span> * Maps from region name to collapseDirection for panel.
* @private
*/
collapseDirections: {
north: 'top',
south: 'bottom',
east: 'right',
west: 'left'
},
manageMargins: true,
panelCollapseAnimate: true,
panelCollapseMode: 'placeholder',
<span id='Ext-layout-container-Border-cfg-regionWeights'> /**
</span> * @cfg {Object} regionWeights
* The default weights to assign to regions in the border layout. These values are
* used when a region does not contain a `weight` property. This object must have
* properties for all regions ("north", "south", "east" and "west").
*
* **IMPORTANT:** Since this is an object, changing its properties will impact ALL
* instances of Border layout. If this is not desired, provide a replacement object as
* a config option instead:
*
* layout: {
* type: 'border',
* regionWeights: {
* west: 20,
* north: 10,
* south: -10,
* east: -20
* }
* }
*
* The region with the highest weight is assigned space from the border before other
* regions. Regions of equal weight are assigned space based on their position in the
* owner's items list (first come, first served).
*/
regionWeights: {
north: 20,
south: 10,
center: 0,
west: -10,
east: -20
},
//----------------------------------
// Layout processing
<span id='Ext-layout-container-Border-method-beginAxis'> /**
</span> * Creates the axis objects for the layout. These are only missing size information
* which is added during {@link #calculate}.
* @private
*/
beginAxis: function (ownerContext, regions, name) {
var me = this,
props = me.axisProps[name],
isVert = !props.horizontal,
sizeProp = props.sizeProp,
totalFlex = 0,
childItems = ownerContext.childItems,
length = childItems.length,
center, i, childContext, centerFlex, comp, region, match, size, type, target, placeholder;
for (i = 0; i < length; ++i) {
childContext = childItems[i];
comp = childContext.target;
childContext.layoutPos = {};
if (comp.region) {
childContext.region = region = comp.region;
childContext.isCenter = comp.isCenter;
childContext.isHorz = comp.isHorz;
childContext.isVert = comp.isVert;
childContext.weight = comp.weight || me.regionWeights[region] || 0;
regions[comp.id] = childContext;
if (comp.isCenter) {
center = childContext;
centerFlex = comp.flex;
ownerContext.centerRegion = center;
continue;
}
if (isVert !== childContext.isVert) {
continue;
}
// process regions "isVert ? north||south : east||center||west"
childContext.reverseWeighting = (region == props.borderEnd);
size = comp[sizeProp];
type = typeof size;
if (!comp.collapsed) {
if (type == 'string' && (match = me.percentageRe.exec(size))) {
childContext.percentage = parseInt(match[1], 10);
} else if (comp.flex) {
totalFlex += childContext.flex = comp.flex;
}
}
}
}
// Special cases for a collapsed center region
if (center) {
target = center.target;
if (placeholder = target.placeholderFor) {
if (!centerFlex && isVert === placeholder.collapsedVertical()) {
// The center region is a placeholder, collapsed in this axis
centerFlex = 0;
center.collapseAxis = name;
}
} else if (target.collapsed && (isVert === target.collapsedVertical())) {
// The center region is a collapsed header, collapsed in this axis
centerFlex = 0;
center.collapseAxis = name;
}
}
if (centerFlex == null) {
// If we still don't have a center flex, default to 1
centerFlex = 1;
}
totalFlex += centerFlex;
return Ext.apply({
before : isVert ? 'top' : 'left',
totalFlex : totalFlex
}, props);
},
beginLayout: function (ownerContext) {
var me = this,
items = me.getLayoutItems(),
pad = me.padding,
type = typeof pad,
padOnContainer = false,
childContext, item, length, i, regions, collapseTarget,
doShow, hidden, region;
// We sync the visibility state of splitters with their region:
if (pad) {
if (type == 'string' || type == 'number') {
pad = Ext.util.Format.parseBox(pad);
}
} else {
pad = ownerContext.getEl('getTargetEl').getPaddingInfo();
padOnContainer = true;
}
ownerContext.outerPad = pad;
ownerContext.padOnContainer = padOnContainer;
for (i = 0, length = items.length; i < length; ++i) {
item = items[i];
collapseTarget = me.getSplitterTarget(item);
if (collapseTarget) {
hidden = !!item.hidden;
if (!collapseTarget.split) {
if (collapseTarget.isCollapsingOrExpanding) {
doShow = !!collapseTarget.collapsed;
}
} else if (hidden !== collapseTarget.hidden) {
doShow = !collapseTarget.hidden;
}
if (doShow === true) {
item.show();
} else if (doShow === false) {
item.hide();
}
}
}
// The above synchronized visibility of splitters with their regions, so we need
// to make this call after that so that childItems and visibleItems are correct:
//
me.callParent(arguments);
items = ownerContext.childItems;
length = items.length;
regions = {};
ownerContext.borderAxisHorz = me.beginAxis(ownerContext, regions, 'horz');
ownerContext.borderAxisVert = me.beginAxis(ownerContext, regions, 'vert');
// Now that weights are assigned to the region's contextItems, we assign those
// same weights to the contextItem for the splitters. We also cross link the
// contextItems for the collapseTarget and its splitter.
for (i = 0; i < length; ++i) {
childContext = items[i];
collapseTarget = me.getSplitterTarget(childContext.target);
if (collapseTarget) { // if (splitter)
region = regions[collapseTarget.id]
if (!region) {
// if the region was hidden it will not be part of childItems, and
// so beginAxis() won't add it to the regions object, so we have
// to create the context item here.
region = ownerContext.getEl(collapseTarget.el, me);
region.region = collapseTarget.region;
}
childContext.collapseTarget = collapseTarget = region;
childContext.weight = collapseTarget.weight;
childContext.reverseWeighting = collapseTarget.reverseWeighting;
collapseTarget.splitter = childContext;
childContext.isHorz = collapseTarget.isHorz;
childContext.isVert = collapseTarget.isVert;
}
}
// Now we want to sort the childItems by their weight.
me.sortWeightedItems(items, 'reverseWeighting');
me.setupSplitterNeighbors(items);
},
calculate: function (ownerContext) {
var me = this,
containerSize = me.getContainerSize(ownerContext),
childItems = ownerContext.childItems,
length = childItems.length,
horz = ownerContext.borderAxisHorz,
vert = ownerContext.borderAxisVert,
pad = ownerContext.outerPad,
padOnContainer = ownerContext.padOnContainer,
i, childContext, childMargins, size, horzPercentTotal, vertPercentTotal;
horz.begin = pad.left;
vert.begin = pad.top;
// If the padding is already on the container we need to add it to the space
// If not on the container, it's "virtual" padding.
horzPercentTotal = horz.end = horz.flexSpace = containerSize.width + (padOnContainer ? pad.left : -pad.right);
vertPercentTotal = vert.end = vert.flexSpace = containerSize.height + (padOnContainer ? pad.top : -pad.bottom);
// Reduce flexSpace on each axis by the fixed/auto sized dimensions of items that
// aren't flexed along that axis.
for (i = 0; i < length; ++i) {
childContext = childItems[i];
childMargins = childContext.getMarginInfo();
// Margins are always fixed size and must be removed from the space used for percentages and flexes
if (childContext.isHorz || childContext.isCenter) {
horz.addUnflexed(childMargins.width);
horzPercentTotal -= childMargins.width;
}
if (childContext.isVert || childContext.isCenter) {
vert.addUnflexed(childMargins.height);
vertPercentTotal -= childMargins.height;
}
// Fixed size components must have their sizes removed from the space used for flex
if (!childContext.flex && !childContext.percentage) {
if (childContext.isHorz || (childContext.isCenter && childContext.collapseAxis === 'horz')) {
size = childContext.getProp('width');
horz.addUnflexed(size);
// splitters should not count towards percentages
if (childContext.collapseTarget) {
horzPercentTotal -= size;
}
} else if (childContext.isVert || (childContext.isCenter && childContext.collapseAxis === 'vert')) {
size = childContext.getProp('height');
vert.addUnflexed(size);
// splitters should not count towards percentages
if (childContext.collapseTarget) {
vertPercentTotal -= size;
}
}
// else ignore center since it is fully flexed
}
}
for (i = 0; i < length; ++i) {
childContext = childItems[i];
childMargins = childContext.getMarginInfo();
// Calculate the percentage sizes. After this calculation percentages are very similar to fixed sizes
if (childContext.percentage) {
if (childContext.isHorz) {
size = Math.ceil(horzPercentTotal * childContext.percentage / 100);
size = childContext.setWidth(size);
horz.addUnflexed(size);
} else if (childContext.isVert) {
size = Math.ceil(vertPercentTotal * childContext.percentage / 100);
size = childContext.setHeight(size);
vert.addUnflexed(size);
}
// center shouldn't have a percentage but if it does it should be ignored
}
}
// If we haven't gotten sizes for all unflexed dimensions on an axis, the flexSpace
// will be NaN so we won't be calculating flexed dimensions until that is resolved.
for (i = 0; i < length; ++i) {
childContext = childItems[i];
if (!childContext.isCenter) {
me.calculateChildAxis(childContext, horz);
me.calculateChildAxis(childContext, vert);
}
}
// Once all items are placed, the final size of the center can be determined. If we
// can determine both width and height, we are done. We use '+' instead of '&&' to
// avoid short-circuiting (we want to call both):
if (me.finishAxis(ownerContext, vert) + me.finishAxis(ownerContext, horz) < 2) {
me.done = false;
} else {
// Size information is published as we place regions but position is hard to do
// that way (while avoiding published multiple times) so we publish all the
// positions at the end.
me.finishPositions(childItems);
}
},
<span id='Ext-layout-container-Border-method-calculateChildAxis'> /**
</span> * Performs the calculations for a region on a specified axis.
* @private
*/
calculateChildAxis: function (childContext, axis) {
var collapseTarget = childContext.collapseTarget,
setSizeMethod = 'set' + axis.sizePropCap,
sizeProp = axis.sizeProp,
childMarginSize = childContext.getMarginInfo()[sizeProp],
region, isBegin, flex, pos, size;
if (collapseTarget) { // if (splitter)
region = collapseTarget.region;
} else {
region = childContext.region;
flex = childContext.flex;
}
isBegin = region == axis.borderBegin;
if (!isBegin && region != axis.borderEnd) {
// a north/south region on the horizontal axis or an east/west region on the
// vertical axis: stretch to fill remaining space:
childContext[setSizeMethod](axis.end - axis.begin - childMarginSize);
pos = axis.begin;
} else {
if (flex) {
size = Math.ceil(axis.flexSpace * (flex / axis.totalFlex));
size = childContext[setSizeMethod](size);
} else if (childContext.percentage) {
// Like getProp but without registering a dependency - we calculated the size, we don't depend on it
size = childContext.peek(sizeProp);
} else {
size = childContext.getProp(sizeProp);
}
size += childMarginSize;
if (isBegin) {
pos = axis.begin;
axis.begin += size;
} else {
axis.end = pos = axis.end - size;
}
}
childContext.layoutPos[axis.posProp] = pos;
},
<span id='Ext-layout-container-Border-method-finishAxis'> /**
</span> * Finishes the calculations on an axis. This basically just assigns the remaining
* space to the center region.
* @private
*/
finishAxis: function (ownerContext, axis) {
var size = axis.end - axis.begin,
center = ownerContext.centerRegion;
if (center) {
center['set' + axis.sizePropCap](size - center.getMarginInfo()[axis.sizeProp]);
center.layoutPos[axis.posProp] = axis.begin;
}
return Ext.isNumber(size) ? 1 : 0;
},
<span id='Ext-layout-container-Border-method-finishPositions'> /**
</span> * Finishes by setting the positions on the child items.
* @private
*/
finishPositions: function (childItems) {
var length = childItems.length,
index, childContext;
for (index = 0; index < length; ++index) {
childContext = childItems[index];
childContext.setProp('x', childContext.layoutPos.x + childContext.marginInfo.left);
childContext.setProp('y', childContext.layoutPos.y + childContext.marginInfo.top);
}
},
getPlaceholder: function (comp) {
return comp.getPlaceholder && comp.getPlaceholder();
},
getSplitterTarget: function (splitter) {
var collapseTarget = splitter.collapseTarget;
if (collapseTarget && collapseTarget.collapsed) {
return collapseTarget.placeholder || collapseTarget;
}
return collapseTarget;
},
isItemBoxParent: function (itemContext) {
return true;
},
isItemShrinkWrap: function (item) {
return true;
},
//----------------------------------
// Event handlers
<span id='Ext-layout-container-Border-method-insertSplitter'> /**
</span> * Inserts the splitter for a given region. A reference to the splitter is also stored
* on the component as "splitter".
* @private
*/
insertSplitter: function (item, index, hidden) {
var region = item.region,
splitter = {
xtype: 'bordersplitter',
collapseTarget: item,
id: item.id + '-splitter',
hidden: hidden,
canResize: item.splitterResize !== false
},
at = index + ((region == 'south' || region == 'east') ? 0 : 1);
// remove the default fixed width or height depending on orientation:
if (item.isHorz) {
splitter.height = null;
} else {
splitter.width = null;
}
if (item.collapseMode == 'mini') {
splitter.collapsedCls = item.collapsedCls;
}
item.splitter = this.owner.add(at, splitter);
},
<span id='Ext-layout-container-Border-method-onAdd'> /**
</span> * Called when a region (actually when any component) is added to the container. The
* region is decorated with some helpful properties (isCenter, isHorz, isVert) and its
* splitter is added if its "split" property is true.
* @private
*/
onAdd: function (item, index) {
var me = this,
placeholderFor = item.placeholderFor,
region = item.region,
split,
hidden;
me.callParent(arguments);
if (region) {
Ext.apply(item, me.regionFlags[region]);
if (region == 'center') {
//<debug>
if (me.centerRegion) {
Ext.Error.raise("Cannot have multiple center regions in a BorderLayout.");
}
//</debug>
me.centerRegion = item;
} else {
item.collapseDirection = this.collapseDirections[region];
split = item.split;
hidden = !!item.hidden;
if ((item.isHorz || item.isVert) && (split || item.collapseMode == 'mini')) {
me.insertSplitter(item, index, hidden || !split);
}
}
if (!item.hasOwnProperty('collapseMode')) {
item.collapseMode = me.panelCollapseMode;
}
if (!item.hasOwnProperty('animCollapse')) {
if (item.collapseMode != 'placeholder') {
// other collapse modes do not animate nicely in a border layout, so
// default them to off:
item.animCollapse = false;
} else {
item.animCollapse = me.panelCollapseAnimate;
}
}
} else if (placeholderFor) {
Ext.apply(item, me.regionFlags[placeholderFor.region]);
item.region = placeholderFor.region;
item.weight = placeholderFor.weight;
}
},
onDestroy: function() {
this.centerRegion = null;
this.callParent();
},
onRemove: function (item) {
var me = this,
region = item.region,
splitter = item.splitter;
if (region) {
if (item.isCenter) {
me.centerRegion = null;
}
delete item.isCenter;
delete item.isHorz;
delete item.isVert;
if (splitter) {
me.owner.doRemove(splitter, true); // avoid another layout
delete item.splitter;
}
}
me.callParent(arguments);
},
//----------------------------------
// Misc
regionFlags: {
center: { isCenter: true, isHorz: false, isVert: false },
north: { isCenter: false, isHorz: false, isVert: true },
south: { isCenter: false, isHorz: false, isVert: true },
west: { isCenter: false, isHorz: true, isVert: false },
east: { isCenter: false, isHorz: true, isVert: false }
},
setupSplitterNeighbors: function (items) {
var edgeRegions = {
//north: null,
//south: null,
//east: null,
//west: null
},
length = items.length,
touchedRegions = this.touchedRegions,
i, j, center, count, edge, comp, region, splitter, touched;
for (i = 0; i < length; ++i) {
comp = items[i].target;
region = comp.region;
if (comp.isCenter) {
center = comp;
} else if (region) {
touched = touchedRegions[region];
for (j = 0, count = touched.length; j < count; ++j) {
edge = edgeRegions[touched[j]];
if (edge) {
edge.neighbors.push(comp);
}
}
if (comp.placeholderFor) {
// placeholder, so grab the splitter for the actual panel
splitter = comp.placeholderFor.splitter;
} else {
splitter = comp.splitter;
}
if (splitter) {
splitter.neighbors = [];
}
edgeRegions[region] = splitter;
}
}
if (center) {
touched = touchedRegions.center;
for (j = 0, count = touched.length; j < count; ++j) {
edge = edgeRegions[touched[j]];
if (edge) {
edge.neighbors.push(center);
}
}
}
},
<span id='Ext-layout-container-Border-property-touchedRegions'> /**
</span> * Lists the regions that would consider an interior region a neighbor. For example,
* a north region would consider an east or west region its neighbords (as well as
* an inner north region).
* @private
*/
touchedRegions: {
center: [ 'north', 'south', 'east', 'west' ],
north: [ 'north', 'east', 'west' ],
south: [ 'south', 'east', 'west' ],
east: [ 'east', 'north', 'south' ],
west: [ 'west', 'north', 'south' ]
},
sizePolicies: {
vert: {
setsWidth: 1,
setsHeight: 0
},
horz: {
setsWidth: 0,
setsHeight: 1
},
flexAll: {
setsWidth: 1,
setsHeight: 1
}
},
getItemSizePolicy: function (item) {
var me = this,
policies = this.sizePolicies,
collapseTarget, size, policy, placeholderFor;
if (item.isCenter) {
placeholderFor = item.placeholderFor;
if (placeholderFor) {
if (placeholderFor.collapsedVertical()) {
return policies.vert;
}
return policies.horz;
}
if (item.collapsed) {
if (item.collapsedVertical()) {
return policies.vert;
}
return policies.horz;
}
return policies.flexAll;
}
collapseTarget = item.collapseTarget;
if (collapseTarget) {
return collapseTarget.isVert ? policies.vert : policies.horz;
}
if (item.region) {
if (item.isVert) {
size = item.height;
policy = policies.vert;
} else {
size = item.width;
policy = policies.horz;
}
if (item.flex || (typeof size == 'string' && me.percentageRe.test(size))) {
return policies.flexAll;
}
return policy;
}
return me.autoSizePolicy;
}
}, function () {
var methods = {
addUnflexed: function (px) {
this.flexSpace = Math.max(this.flexSpace - px, 0);
}
},
props = this.prototype.axisProps;
Ext.apply(props.horz, methods);
Ext.apply(props.vert, methods);
});
</pre>
</body>
</html>