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