3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
8 * @class Ext.QuickTips
\r
9 * <p>Provides attractive and customizable tooltips for any element. The QuickTips
\r
10 * singleton is used to configure and manage tooltips globally for multiple elements
\r
11 * in a generic manner. To create individual tooltips with maximum customizability,
\r
12 * you should consider either {@link Ext.Tip} or {@link Ext.ToolTip}.</p>
\r
13 * <p>Quicktips can be configured via tag attributes directly in markup, or by
\r
14 * registering quick tips programmatically via the {@link #register} method.</p>
\r
15 * <p>The singleton's instance of {@link Ext.QuickTip} is available via
\r
16 * {@link #getQuickTip}, and supports all the methods, and all the all the
\r
17 * configuration properties of Ext.QuickTip. These settings will apply to all
\r
18 * tooltips shown by the singleton.</p>
\r
19 * <p>Below is the summary of the configuration properties which can be used.
\r
20 * For detailed descriptions see {@link #getQuickTip}</p>
\r
21 * <p><b>QuickTips singleton configs (all are optional)</b></p>
\r
22 * <div class="mdetail-params"><ul><li>dismissDelay</li>
\r
23 * <li>hideDelay</li>
\r
26 * <li>showDelay</li>
\r
27 * <li>trackMouse</li></ul></div>
\r
28 * <p><b>Target element configs (optional unless otherwise noted)</b></p>
\r
29 * <div class="mdetail-params"><ul><li>autoHide</li>
\r
31 * <li>dismissDelay (overrides singleton value)</li>
\r
32 * <li>target (required)</li>
\r
33 * <li>text (required)</li>
\r
35 * <li>width</li></ul></div>
\r
36 * <p>Here is an example showing how some of these config options could be used:</p>
\r
38 // Init the singleton. Any tag-based quick tips will start working.
\r
39 Ext.QuickTips.init();
\r
41 // Apply a set of config properties to the singleton
\r
42 Ext.apply(Ext.QuickTips.getQuickTip(), {
\r
49 // Manually register a quick tip for a specific element
\r
50 Ext.QuickTips.register({
\r
52 title: 'My Tooltip',
\r
53 text: 'This tooltip was added in code',
\r
58 * <p>To register a quick tip in markup, you simply add one or more of the valid QuickTip attributes prefixed with
\r
59 * the <b>ext:</b> namespace. The HTML element itself is automatically set as the quick tip target. Here is the summary
\r
60 * of supported attributes (optional unless otherwise noted):</p>
\r
61 * <ul><li><b>hide</b>: Specifying "user" is equivalent to setting autoHide = false. Any other value will be the
\r
62 * same as autoHide = true.</li>
\r
63 * <li><b>qclass</b>: A CSS class to be applied to the quick tip (equivalent to the 'cls' target element config).</li>
\r
64 * <li><b>qtip (required)</b>: The quick tip text (equivalent to the 'text' target element config).</li>
\r
65 * <li><b>qtitle</b>: The quick tip title (equivalent to the 'title' target element config).</li>
\r
66 * <li><b>qwidth</b>: The quick tip width (equivalent to the 'width' target element config).</li></ul>
\r
67 * <p>Here is an example of configuring an HTML element to display a tooltip from markup:</p>
\r
69 // Add a quick tip to an HTML button
\r
70 <input type="button" value="OK" ext:qtitle="OK Button" ext:qwidth="100"
\r
71 ext:qtip="This is a quick tip from markup!"></input>
\r
75 Ext.QuickTips = function(){
\r
76 var tip, locks = [];
\r
79 * Initialize the global QuickTips instance and prepare any quick tips.
\r
80 * @param {Boolean} autoRender True to render the QuickTips container immediately to preload images. (Defaults to true)
\r
82 init : function(autoRender){
\r
85 Ext.onReady(function(){
\r
86 Ext.QuickTips.init(autoRender);
\r
90 tip = new Ext.QuickTip({elements:'header,body'});
\r
91 if(autoRender !== false){
\r
92 tip.render(Ext.getBody());
\r
98 * Enable quick tips globally.
\r
100 enable : function(){
\r
103 if(locks.length < 1){
\r
110 * Disable quick tips globally.
\r
112 disable : function(){
\r
120 * Returns true if quick tips are enabled, else false.
\r
121 * @return {Boolean}
\r
123 isEnabled : function(){
\r
124 return tip !== undefined && !tip.disabled;
\r
128 * Gets the global QuickTips instance.
\r
130 getQuickTip : function(){
\r
135 * Configures a new quick tip instance and assigns it to a target element. See
\r
136 * {@link Ext.QuickTip#register} for details.
\r
137 * @param {Object} config The config object
\r
139 register : function(){
\r
140 tip.register.apply(tip, arguments);
\r
144 * Removes any registered quick tip from the target element and destroys it.
\r
145 * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
\r
147 unregister : function(){
\r
148 tip.unregister.apply(tip, arguments);
\r
152 * Alias of {@link #register}.
\r
153 * @param {Object} config The config object
\r
156 tip.register.apply(tip, arguments);
\r