X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..f562e4c6e5fac7bcb445985b99acbea4d706e6f0:/docs/source/Tip.html diff --git a/docs/source/Tip.html b/docs/source/Tip.html index 34e1c156..76763f4b 100644 --- a/docs/source/Tip.html +++ b/docs/source/Tip.html @@ -1,171 +1,96 @@ +
- +/*! - * Ext JS Library 3.3.1 - * Copyright(c) 2006-2010 Sencha Inc. - * licensing@sencha.com - * http://www.sencha.com/license - */ -/** - * @class Ext.Tip - * @extends Ext.Panel - * @xtype tip - * This is the base class for {@link Ext.QuickTip} and {@link Ext.Tooltip} that provides the basic layout and - * positioning that all tip-based classes require. This class can be used directly for simple, statically-positioned - * tips that are displayed programmatically, or it can be extended to provide custom tip implementations. - * @constructor - * Create a new Tip - * @param {Object} config The configuration options + +- \ No newline at end of file +/** + * Component layout for Tip/ToolTip/etc. components + * @class Ext.layout.component.Tip + * @extends Ext.layout.component.Dock + * @private */ -Ext.Tip = Ext.extend(Ext.Panel, { - /** - * @cfg {Boolean} closable True to render a close tool button into the tooltip header (defaults to false). - */ - /** - * @cfg {Number} width - * Width in pixels of the tip (defaults to auto). Width will be ignored if it exceeds the bounds of - * {@link #minWidth} or {@link #maxWidth}. The maximum supported value is 500. - */ - /** - * @cfg {Number} minWidth The minimum width of the tip in pixels (defaults to 40). - */ - minWidth : 40, - /** - * @cfg {Number} maxWidth The maximum width of the tip in pixels (defaults to 300). The maximum supported value is 500. - */ - maxWidth : 300, - /** - * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" - * for bottom-right shadow (defaults to "sides"). - */ - shadow : "sides", - /** - * @cfg {String} defaultAlign Experimental. The default {@link Ext.Element#alignTo} anchor position value - * for this tip relative to its element of origin (defaults to "tl-bl?"). - */ - defaultAlign : "tl-bl?", - autoRender: true, - quickShowInterval : 250, - - // private panel overrides - frame:true, - hidden:true, - baseCls: 'x-tip', - floating:{shadow:true,shim:true,useDisplay:true,constrain:false}, - autoHeight:true, - closeAction: 'hide', +Ext.define('Ext.layout.component.Tip', { - // private - initComponent : function(){ - Ext.Tip.superclass.initComponent.call(this); - if(this.closable && !this.title){ - this.elements += ',header'; - } - }, + /* Begin Definitions */ - // private - afterRender : function(){ - Ext.Tip.superclass.afterRender.call(this); - if(this.closable){ - this.addTool({ - id: 'close', - handler: this[this.closeAction], - scope: this - }); - } - }, - - /** - * Shows this tip at the specified XY position. Example usage: - *+}); +- * @param {Array} xy An array containing the x and y coordinates - */ - showAt : function(xy){ - Ext.Tip.superclass.show.call(this); - if(this.measureWidth !== false && (!this.initialConfig || typeof this.initialConfig.width != 'number')){ - this.doAutoWidth(); - } - if(this.constrainPosition){ - xy = this.el.adjustForConstraints(xy); - } - this.setPagePosition(xy[0], xy[1]); - }, + alias: ['layout.tip'], - // protected - doAutoWidth : function(adjust){ - adjust = adjust || 0; - var bw = this.body.getTextWidth(); - if(this.title){ - bw = Math.max(bw, this.header.child('span').getTextWidth(this.title)); - } - bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr") + adjust; - this.setWidth(bw.constrain(this.minWidth, this.maxWidth)); - - // IE7 repaint bug on initial show - if(Ext.isIE7 && !this.repainted){ - this.el.repaint(); - this.repainted = true; - } - }, + extend: 'Ext.layout.component.Dock', - /** - * Experimental. Shows this tip at a position relative to another element using a standard {@link Ext.Element#alignTo} - * anchor position value. Example usage: - *-// Show the tip at x:50 and y:100 -tip.showAt([50,100]); -
- * @param {Mixed} el An HTMLElement, Ext.Element or string id of the target element to align to - * @param {String} position (optional) A valid {@link Ext.Element#alignTo} anchor position (defaults to 'tl-br?' or - * {@link #defaultAlign} if specified). - */ - showBy : function(el, pos){ - if(!this.rendered){ - this.render(Ext.getBody()); - } - this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign)); - }, + type: 'tip', + + onLayout: function(width, height) { + var me = this, + owner = me.owner, + el = owner.el, + minWidth, + maxWidth, + naturalWidth, + constrainedWidth, + xy = el.getXY(); - initDraggable : function(){ - this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable); - this.header.addClass('x-tip-draggable'); - } -}); + // Position offscreen so the natural width is not affected by the viewport's right edge + el.setXY([-9999,-9999]); -Ext.reg('tip', Ext.Tip); + // Calculate initial layout + this.callParent(arguments); -// private - custom Tip DD implementation -Ext.Tip.DD = function(tip, config){ - Ext.apply(this, config); - this.tip = tip; - Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id); - this.setHandleElId(tip.header.id); - this.scroll = false; -}; + // 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]); + } + } -Ext.extend(Ext.Tip.DD, Ext.dd.DD, { - moveOnly:true, - scroll:false, - headerOffsets:[100, 25], - startDrag : function(){ - this.tip.el.disableShadow(); + // Restore position + el.setXY(xy); }, - endDrag : function(e){ - this.tip.el.enableShadow(true); + + 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; } -});-// Show the tip at the default position ('tl-br?') -tip.showBy('my-el'); + /* End Definitions */ -// Show the tip's top-left corner anchored to the element's top-right corner -tip.showBy('my-el', 'tl-tr'); -