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