Upgrade to ExtJS 3.2.0 - Released 03/30/2010
[extjs.git] / docs / source / Tip.html
index 0e95ba5..20a04a0 100644 (file)
-<html>\r
-<head>\r
-  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    \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
- * @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(adjust){\r
-        adjust = adjust || 0;\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") + adjust;\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>    \r
-</body>\r
+<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>
+</head>
+<body  onload="prettyPrint();">
+    <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.2.0
+ * Copyright(c) 2006-2010 Ext JS, Inc.
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+<div id="cls-Ext.Tip"></div>/**
+ * @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
+ */
+Ext.Tip = Ext.extend(Ext.Panel, {
+    <div id="cfg-Ext.Tip-closable"></div>/**
+     * @cfg {Boolean} closable True to render a close tool button into the tooltip header (defaults to false).
+     */
+    <div id="cfg-Ext.Tip-width"></div>/**
+     * @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.
+     */
+    <div id="cfg-Ext.Tip-minWidth"></div>/**
+     * @cfg {Number} minWidth The minimum width of the tip in pixels (defaults to 40).
+     */
+    minWidth : 40,
+    <div id="cfg-Ext.Tip-maxWidth"></div>/**
+     * @cfg {Number} maxWidth The maximum width of the tip in pixels (defaults to 300).  The maximum supported value is 500.
+     */
+    maxWidth : 300,
+    <div id="cfg-Ext.Tip-shadow"></div>/**
+     * @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",
+    <div id="cfg-Ext.Tip-defaultAlign"></div>/**
+     * @cfg {String} defaultAlign <b>Experimental</b>. 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',
+
+    // private
+    initComponent : function(){
+        Ext.Tip.superclass.initComponent.call(this);
+        if(this.closable && !this.title){
+            this.elements += ',header';
+        }
+    },
+
+    // private
+    afterRender : function(){
+        Ext.Tip.superclass.afterRender.call(this);
+        if(this.closable){
+            this.addTool({
+                id: 'close',
+                handler: this[this.closeAction],
+                scope: this
+            });
+        }
+    },
+
+    <div id="method-Ext.Tip-showAt"></div>/**
+     * Shows this tip at the specified XY position.  Example usage:
+     * <pre><code>
+// Show the tip at x:50 and y:100
+tip.showAt([50,100]);
+</code></pre>
+     * @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]);
+    },
+
+    // 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;
+        }
+    },
+
+    <div id="method-Ext.Tip-showBy"></div>/**
+     * <b>Experimental</b>. Shows this tip at a position relative to another element using a standard {@link Ext.Element#alignTo}
+     * anchor position value.  Example usage:
+     * <pre><code>
+// Show the tip at the default position ('tl-br?')
+tip.showBy('my-el');
+
+// Show the tip's top-left corner anchored to the element's top-right corner
+tip.showBy('my-el', 'tl-tr');
+</code></pre>
+     * @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));
+    },
+
+    initDraggable : function(){
+        this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
+        this.header.addClass('x-tip-draggable');
+    }
+});
+
+Ext.reg('tip', Ext.Tip);
+
+// 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;
+};
+
+Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
+    moveOnly:true,
+    scroll:false,
+    headerOffsets:[100, 25],
+    startDrag : function(){
+        this.tip.el.disableShadow();
+    },
+    endDrag : function(e){
+        this.tip.el.enableShadow(true);
+    }
+});</pre>    
+</body>
 </html>
\ No newline at end of file