Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / Tip.html
diff --git a/docs/source/Tip.html b/docs/source/Tip.html
new file mode 100644 (file)
index 0000000..df04629
--- /dev/null
@@ -0,0 +1,160 @@
+<html>\r
+<head>\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.Tip"></div>/**\r
+ * @class Ext.Tip\r
+ * @extends Ext.Panel\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
+// 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>    \r
+</body>\r
+</html>
\ No newline at end of file