Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / docs / source / Tool.html
index ea829c6..153c292 100644 (file)
@@ -3,8 +3,8 @@
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <title>The source code</title>
-  <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
-  <script type="text/javascript" src="../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>
 </head>
 <body onload="prettyPrint(); highlight();">
   <pre class="prettyprint lang-js"><span id='Ext-panel-Tool'>/**
-</span> * @class Ext.panel.Tool
- * @extends Ext.Component
-
-This class is used to display small visual icons in the header of a panel. There are a set of
-25 icons that can be specified by using the {@link #type} config. The {@link #handler} config
-can be used to provide a function that will respond to any click events. In general, this class
-will not be instantiated directly, rather it will be created by specifying the {@link Ext.panel.Panel#tools}
-configuration on the Panel itself.
-
-__Example Usage__
-
-    Ext.create('Ext.panel.Panel', {
-       width: 200,
-       height: 200,
-       renderTo: document.body,
-       title: 'A Panel',
-       tools: [{
-           type: 'help',
-           handler: function(){
-               // show help here
-           }
-       }, {
-           itemId: 'refresh',
-           type: 'refresh',
-           hidden: true,
-           handler: function(){
-               // do refresh
-           }
-       }, {
-           type: 'search',
-           handler: function(event, target, owner, tool){
-               // do search
-               owner.child('#refresh').show();
-           }
-       }]
-    });
-
- * @markdown
+</span> * This class is used to display small visual icons in the header of a panel. There are a set of
+ * 25 icons that can be specified by using the {@link #type} config. The {@link #handler} config
+ * can be used to provide a function that will respond to any click events. In general, this class
+ * will not be instantiated directly, rather it will be created by specifying the {@link Ext.panel.Panel#tools}
+ * configuration on the Panel itself.
+ *
+ *     @example
+ *     Ext.create('Ext.panel.Panel', {
+ *         width: 200,
+ *         height: 200,
+ *         renderTo: document.body,
+ *         title: 'A Panel',
+ *         tools: [{
+ *             type: 'help',
+ *             handler: function(){
+ *                 // show help here
+ *             }
+ *         }, {
+ *             itemId: 'refresh',
+ *             type: 'refresh',
+ *             hidden: true,
+ *             handler: function(){
+ *                 // do refresh
+ *             }
+ *         }, {
+ *             type: 'search',
+ *             handler: function(event, target, owner, tool){
+ *                 // do search
+ *                 owner.child('#refresh').show();
+ *             }
+ *         }]
+ *     });
  */
 Ext.define('Ext.panel.Tool', {
     extend: 'Ext.Component',
@@ -65,65 +59,67 @@ Ext.define('Ext.panel.Tool', {
     toolPressedCls: Ext.baseCSSPrefix + 'tool-pressed',
     toolOverCls: Ext.baseCSSPrefix + 'tool-over',
     ariaRole: 'button',
-    renderTpl: ['&lt;img src=&quot;{blank}&quot; class=&quot;{baseCls}-{type}&quot; role=&quot;presentation&quot;/&gt;'],
-    
+    renderTpl: ['&lt;img id=&quot;{id}-toolEl&quot; src=&quot;{blank}&quot; class=&quot;{baseCls}-{type}&quot; role=&quot;presentation&quot;/&gt;'],
+
 <span id='Ext-panel-Tool-cfg-handler'>    /**
 </span>     * @cfg {Function} handler
-     * A function to execute when the tool is clicked.
-     * Arguments passed are:
-     * &lt;ul&gt;
-     * &lt;li&gt;&lt;b&gt;event&lt;/b&gt; : Ext.EventObject&lt;div class=&quot;sub-desc&quot;&gt;The click event.&lt;/div&gt;&lt;/li&gt;
-     * &lt;li&gt;&lt;b&gt;toolEl&lt;/b&gt; : Ext.core.Element&lt;div class=&quot;sub-desc&quot;&gt;The tool Element.&lt;/div&gt;&lt;/li&gt;
-     * &lt;li&gt;&lt;b&gt;panel&lt;/b&gt; : Ext.panel.Panel&lt;div class=&quot;sub-desc&quot;&gt;The host Panel&lt;/div&gt;&lt;/li&gt;
-     * &lt;li&gt;&lt;b&gt;tool&lt;/b&gt; : Ext.panel.Tool&lt;div class=&quot;sub-desc&quot;&gt;The tool object&lt;/div&gt;&lt;/li&gt;
-     * &lt;/ul&gt;
+     * A function to execute when the tool is clicked. Arguments passed are:
+     *
+     * - **event** : Ext.EventObject - The click event.
+     * - **toolEl** : Ext.Element - The tool Element.
+     * - **owner** : Ext.panel.Header - The host panel header.
+     * - **tool** : Ext.panel.Tool - The tool object
      */
-    
+
 <span id='Ext-panel-Tool-cfg-scope'>    /**
 </span>     * @cfg {Object} scope
      * The scope to execute the {@link #handler} function. Defaults to the tool.
      */
-    
+
 <span id='Ext-panel-Tool-cfg-type'>    /**
 </span>     * @cfg {String} type
      * The type of tool to render. The following types are available:
-     * &lt;ul&gt;
-     * &lt;li&gt;close&lt;/li&gt;
-     * &lt;li&gt;collapse&lt;/li&gt;
-     * &lt;li&gt;down&lt;/li&gt;
-     * &lt;li&gt;expand&lt;/li&gt;
-     * &lt;li&gt;gear&lt;/li&gt;
-     * &lt;li&gt;help&lt;/li&gt;
-     * &lt;li&gt;left&lt;/li&gt;
-     * &lt;li&gt;maximize&lt;/li&gt;
-     * &lt;li&gt;minimize&lt;/li&gt;
-     * &lt;li&gt;minus&lt;/li&gt;
-     * &lt;li&gt;move&lt;/li&gt;
-     * &lt;li&gt;next&lt;/li&gt;
-     * &lt;li&gt;pin&lt;/li&gt;
-     * &lt;li&gt;plus&lt;/li&gt;
-     * &lt;li&gt;prev&lt;/li&gt;
-     * &lt;li&gt;print&lt;/li&gt;
-     * &lt;li&gt;refresh&lt;/li&gt;
-     * &lt;li&gt;resize&lt;/li&gt;
-     * &lt;li&gt;restore&lt;/li&gt;
-     * &lt;li&gt;right&lt;/li&gt;
-     * &lt;li&gt;save&lt;/li&gt;
-     * &lt;li&gt;search&lt;/li&gt;
-     * &lt;li&gt;toggle&lt;/li&gt;
-     * &lt;li&gt;unpin&lt;/li&gt;
-     * &lt;li&gt;up&lt;/li&gt;
-     * &lt;/ul&gt;
+     *
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-close&quot;&gt;&lt;/span&gt; close
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-minimize&quot;&gt;&lt;/span&gt; minimize
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-maximize&quot;&gt;&lt;/span&gt; maximize
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-restore&quot;&gt;&lt;/span&gt; restore
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-toggle&quot;&gt;&lt;/span&gt; toggle
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-gear&quot;&gt;&lt;/span&gt; gear
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-prev&quot;&gt;&lt;/span&gt; prev
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-next&quot;&gt;&lt;/span&gt; next
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-pin&quot;&gt;&lt;/span&gt; pin
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-unpin&quot;&gt;&lt;/span&gt; unpin
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-right&quot;&gt;&lt;/span&gt; right
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-left&quot;&gt;&lt;/span&gt; left
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-down&quot;&gt;&lt;/span&gt; down
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-up&quot;&gt;&lt;/span&gt; up
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-refresh&quot;&gt;&lt;/span&gt; refresh
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-plus&quot;&gt;&lt;/span&gt; plus
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-minus&quot;&gt;&lt;/span&gt; minus
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-search&quot;&gt;&lt;/span&gt; search
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-save&quot;&gt;&lt;/span&gt; save
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-help&quot;&gt;&lt;/span&gt; help
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-print&quot;&gt;&lt;/span&gt; print
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-expand&quot;&gt;&lt;/span&gt; expand
+     * - &lt;span class=&quot;x-tool&quot;&gt;&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot; class=&quot;x-tool-collapse&quot;&gt;&lt;/span&gt; collapse
      */
-    
+
 <span id='Ext-panel-Tool-cfg-tooltip'>    /**
-</span>     * @cfg {String/Object} tooltip 
-     * The tooltip for the tool - can be a string to be used as innerHTML (html tags are accepted) or QuickTips config object
+</span>     * @cfg {String/Object} tooltip
+     * The tooltip for the tool - can be a string to be used as innerHTML (html tags are accepted) or QuickTips config
+     * object
+     */
+
+<span id='Ext-panel-Tool-cfg-tooltipType'>     /**
+</span>     * @cfg {String} tooltipType
+     * The type of tooltip to use. Either 'qtip' (default) for QuickTips or 'title' for title attribute.
      */
-    
+    tooltipType: 'qtip',
+
 <span id='Ext-panel-Tool-cfg-stopEvent'>    /**
 </span>     * @cfg {Boolean} stopEvent
-     * Defaults to true. Specify as false to allow click event to propagate.
+     * Specify as false to allow click event to propagate.
      */
     stopEvent: true,
 
@@ -138,41 +134,41 @@ Ext.define('Ext.panel.Tool', {
              */
             'click'
         );
-        
+
         //&lt;debug&gt;
         var types = [
-            'close', 
-            'collapse', 
-            'down', 
-            'expand', 
-            'gear', 
-            'help', 
-            'left', 
-            'maximize', 
-            'minimize', 
-            'minus', 
-            'move', 
-            'next', 
-            'pin', 
-            'plus', 
-            'prev', 
-            'print', 
-            'refresh', 
-            'resize', 
-            'restore', 
-            'right', 
-            'save', 
-            'search', 
+            'close',
+            'collapse',
+            'down',
+            'expand',
+            'gear',
+            'help',
+            'left',
+            'maximize',
+            'minimize',
+            'minus',
+            'move',
+            'next',
+            'pin',
+            'plus',
+            'prev',
+            'print',
+            'refresh',
+            'resize',
+            'restore',
+            'right',
+            'save',
+            'search',
             'toggle',
-            'unpin', 
+            'unpin',
             'up'
         ];
-        
+
         if (me.id &amp;&amp; Ext.Array.indexOf(types, me.id) &gt; -1 &amp;&amp; Ext.global.console) {
             Ext.global.console.warn('When specifying a tool you should use the type option, the id can conflict now that tool is a Component');
         }
         //&lt;/debug&gt;
-        
+
         me.type = me.type || me.id;
 
         Ext.applyIf(me.renderData, {
@@ -180,22 +176,29 @@ Ext.define('Ext.panel.Tool', {
             blank: Ext.BLANK_IMAGE_URL,
             type: me.type
         });
-        me.renderSelectors.toolEl = '.' + me.baseCls + '-' + me.type;
+
+        me.addChildEls('toolEl');
+
+        // alias qtip, should use tooltip since it's what we have in the docs
+        me.tooltip = me.tooltip || me.qtip;
         me.callParent();
     },
 
     // inherit docs
     afterRender: function() {
-        var me = this;
+        var me = this,
+            attr;
+
         me.callParent(arguments);
-        if (me.qtip) {
-            if (Ext.isObject(me.qtip)) {
+        if (me.tooltip) {
+            if (Ext.isObject(me.tooltip)) {
                 Ext.tip.QuickTipManager.register(Ext.apply({
                     target: me.id
-                }, me.qtip));
+                }, me.tooltip));
             }
             else {
-                me.toolEl.dom.qtip = me.qtip;
+                attr = me.tooltipType == 'qtip' ? 'data-qtip' : 'title';
+                me.toolEl.dom.setAttribute(attr, me.tooltip);
             }
         }
 
@@ -209,13 +212,13 @@ Ext.define('Ext.panel.Tool', {
     },
 
 <span id='Ext-panel-Tool-method-setType'>    /**
-</span>     * Set the type of the tool. Allows the icon to be changed.
+</span>     * Sets the type of the tool. Allows the icon to be changed.
      * @param {String} type The new type. See the {@link #type} config.
      * @return {Ext.panel.Tool} this
      */
     setType: function(type) {
         var me = this;
-        
+
         me.type = type;
         if (me.rendered) {
             me.toolEl.dom.className = me.baseCls + '-' + type;
@@ -233,7 +236,7 @@ Ext.define('Ext.panel.Tool', {
     },
 
 <span id='Ext-panel-Tool-method-onClick'>    /**
-</span>     * Fired when the tool element is clicked
+</span>     * Called when the tool element is clicked
      * @private
      * @param {Ext.EventObject} e
      * @param {HTMLElement} target The target element
@@ -241,7 +244,7 @@ Ext.define('Ext.panel.Tool', {
     onClick: function(e, target) {
         var me = this,
             owner;
-            
+
         if (me.disabled) {
             return false;
         }
@@ -259,17 +262,17 @@ Ext.define('Ext.panel.Tool', {
         me.fireEvent('click', me, e);
         return true;
     },
-    
+
     // inherit docs
     onDestroy: function(){
         if (Ext.isObject(this.tooltip)) {
             Ext.tip.QuickTipManager.unregister(this.id);
-        }    
+        }
         this.callParent();
     },
 
 <span id='Ext-panel-Tool-method-onMouseDown'>    /**
-</span>     * Called then the user pressing their mouse button down on a tool
+</span>     * Called when the user presses their mouse button down on a tool
      * Adds the press class ({@link #toolPressedCls})
      * @private
      */