-<html>\r
-<head>\r
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \r
- <title>The source code</title>\r
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body onload="prettyPrint();">\r
- <pre class="prettyprint lang-js"><div id="cls-Ext.layout.AnchorLayout"></div>/**
+<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>
+</head>
+<body onload="prettyPrint();">
+ <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.2.1
+ * Copyright(c) 2006-2010 Ext JS, Inc.
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+<div id="cls-Ext.layout.AnchorLayout"></div>/**
* @class Ext.layout.AnchorLayout
* @extends Ext.layout.ContainerLayout
* <p>This is a layout that enables anchoring of contained elements relative to the container's dimensions.
*/
// private
- monitorResize:true,
- type: 'anchor',
+ monitorResize : true,
+
+ type : 'anchor',
+
+ <div id="cfg-Ext.layout.AnchorLayout-defaultAnchor"></div>/**
+ * @cfg {String} defaultAnchor
+ *
+ * default anchor for all child container items applied if no anchor or specific width is set on the child item. Defaults to '100%'.
+ *
+ */
+ defaultAnchor : '100%',
+
+ parseAnchorRE : /^(r|right|b|bottom)$/i,
getLayoutTargetSize : function() {
var target = this.container.getLayoutTarget();
ah = ct.initialConfig.height;
}
- var cs = this.getRenderedItems(ct), len = cs.length, i, c, a, cw, ch, el, vs;
+ var cs = this.getRenderedItems(ct), len = cs.length, i, c, a, cw, ch, el, vs, boxes = [];
for(i = 0; i < len; i++){
c = cs[i];
el = c.getPositionEl();
+
+ // If a child container item has no anchor and no specific width, set the child to the default anchor size
+ if (!c.anchor && c.items && !Ext.isNumber(c.width) && !(Ext.isIE6 && Ext.isStrict)){
+ c.anchor = this.defaultAnchor;
+ }
+
if(c.anchor){
a = c.anchorSpec;
if(!a){ // cache all anchor values
ch = a.bottom ? this.adjustHeightAnchor(a.bottom(h) - el.getMargins('tb'), c) : undefined;
if(cw || ch){
- c.setSize(cw || undefined, ch || undefined);
+ boxes.push({
+ comp: c,
+ width: cw || undefined,
+ height: ch || undefined
+ });
}
}
}
+ for (i = 0, len = boxes.length; i < len; i++) {
+ c = boxes[i];
+ c.comp.setSize(c.width, c.height);
+ }
},
// private
parseAnchor : function(a, start, cstart){
if(a && a != 'none'){
var last;
- if(/^(r|right|b|bottom)$/i.test(a)){ // standard anchor
+ // standard anchor
+ if(this.parseAnchorRE.test(a)){
var diff = cstart - start;
return function(v){
if(v !== last){
return v - diff;
}
}
+ // percentage
}else if(a.indexOf('%') != -1){
- var ratio = parseFloat(a.replace('%', ''))*.01; // percentage
+ var ratio = parseFloat(a.replace('%', ''))*.01;
return function(v){
if(v !== last){
last = v;
return Math.floor(v*ratio);
}
}
+ // simple offset adjustment
}else{
a = parseInt(a, 10);
- if(!isNaN(a)){ // simple offset adjustment
+ if(!isNaN(a)){
return function(v){
if(v !== last){
last = v;
*/
});
Ext.Container.LAYOUTS['anchor'] = Ext.layout.AnchorLayout;
-</pre> \r
-</body>\r
+</pre>
+</body>
</html>
\ No newline at end of file