X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/src/layout/component/Tip.js diff --git a/src/layout/component/Tip.js b/src/layout/component/Tip.js new file mode 100644 index 00000000..ca99583c --- /dev/null +++ b/src/layout/component/Tip.js @@ -0,0 +1,76 @@ +/** + * Component layout for Tip/ToolTip/etc. components + * @class Ext.layout.component.Tip + * @extends Ext.layout.component.Dock + * @private + */ + +Ext.define('Ext.layout.component.Tip', { + + /* Begin Definitions */ + + alias: ['layout.tip'], + + extend: 'Ext.layout.component.Dock', + + /* End Definitions */ + + type: 'tip', + + onLayout: function(width, height) { + var me = this, + owner = me.owner, + el = owner.el, + minWidth, + maxWidth, + naturalWidth, + constrainedWidth, + xy = el.getXY(); + + // Position offscreen so the natural width is not affected by the viewport's right edge + el.setXY([-9999,-9999]); + + // Calculate initial layout + this.callParent(arguments); + + // Handle min/maxWidth for auto-width tips + if (!Ext.isNumber(width)) { + minWidth = owner.minWidth; + maxWidth = owner.maxWidth; + // IE6/7 in strict mode have a problem doing an autoWidth + if (Ext.isStrict && (Ext.isIE6 || Ext.isIE7)) { + constrainedWidth = me.doAutoWidth(); + } else { + naturalWidth = el.getWidth(); + } + if (naturalWidth < minWidth) { + constrainedWidth = minWidth; + } + else if (naturalWidth > maxWidth) { + constrainedWidth = maxWidth; + } + if (constrainedWidth) { + this.callParent([constrainedWidth, height]); + } + } + + // Restore position + el.setXY(xy); + }, + + doAutoWidth: function(){ + var me = this, + owner = me.owner, + body = owner.body, + width = body.getTextWidth(); + + if (owner.header) { + width = Math.max(width, owner.header.getWidth()); + } + if (!Ext.isDefined(me.frameWidth)) { + me.frameWidth = owner.el.getWidth() - body.getWidth(); + } + width += me.frameWidth + body.getPadding('lr'); + return width; + } +});