X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6e39d509471fe9b4e2660e0d1631b350d0c66f40..b37ceabb82336ee82757cd32efe353cfab8ec267:/src/widgets/layout/AnchorLayout.js diff --git a/src/widgets/layout/AnchorLayout.js b/src/widgets/layout/AnchorLayout.js index 612394a8..e750a6b1 100644 --- a/src/widgets/layout/AnchorLayout.js +++ b/src/widgets/layout/AnchorLayout.js @@ -1,6 +1,6 @@ /*! - * Ext JS Library 3.1.0 - * Copyright(c) 2006-2009 Ext JS, LLC + * Ext JS Library 3.2.2 + * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license */ @@ -91,20 +91,33 @@ anchor: '-50 75%' */ // private - monitorResize:true, + monitorResize : true, - // private - // deprecate - getAnchorViewSize : function(ct, target){ - return target.dom == document.body ? - target.getViewSize(true) : target.getStyleSize(); + type : 'anchor', + + /** + * @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(); + if (!target) { + return {}; + } + // Style Sized (scrollbars not included) + return target.getStyleSize(); }, // private onLayout : function(ct, target){ Ext.layout.AnchorLayout.superclass.onLayout.call(this, ct, target); - - var size = target.getViewSize(true); + var size = this.getLayoutTargetSize(); var w = size.width, h = size.height; @@ -126,10 +139,16 @@ anchor: '-50 75%' ah = ct.initialConfig.height; } - var cs = ct.items.items, 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 @@ -143,17 +162,26 @@ anchor: '-50 75%' 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){ @@ -161,17 +189,19 @@ anchor: '-50 75%' 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;