source: trunk/web/addons/job_monarch/lib/extjs/source/widgets/tips/QuickTips.js @ 619

Last change on this file since 619 was 619, checked in by ramonb, 15 years ago

lib/:

  • added new AJAX dependancies: ExtJS, pChart, Lightbox2
File size: 5.7 KB
Line 
1/*
2 * Ext JS Library 2.2.1
3 * Copyright(c) 2006-2009, Ext JS, LLC.
4 * licensing@extjs.com
5 *
6 * http://extjs.com/license
7 */
8
9/**
10 * @class Ext.QuickTips
11 * <p>Provides attractive and customizable tooltips for any element. The QuickTips
12 * singleton is used to configure and manage tooltips globally for multiple elements
13 * in a generic manner.  To create individual tooltips with maximum customizability,
14 * you should consider either {@link Ext.Tip} or {@link Ext.ToolTip}.</p>
15 * <p>Quicktips can be configured via tag attributes directly in markup, or by
16 * registering quick tips programmatically via the {@link #register} method.</p>
17 * <p>The singleton's instance of {@link Ext.QuickTip} is available via
18 * {@link #getQuickTip}, and supports all the methods, and all the all the
19 * configuration properties of Ext.QuickTip. These settings will apply to all
20 * tooltips shown by the singleton.</p>
21 * <p>Below is the summary of the configuration properties which can be used.
22 * For detailed descriptions see {@link #getQuickTip}</p>
23 * <p><b>QuickTips singleton configs (all are optional)</b></p>
24 * <div class="mdetail-params"><ul><li>dismissDelay</li>
25 * <li>hideDelay</li>
26 * <li>maxWidth</li>
27 * <li>minWidth</li>
28 * <li>showDelay</li>
29 * <li>trackMouse</li></ul></div>
30 * <p><b>Target element configs (optional unless otherwise noted)</b></p>
31 * <div class="mdetail-params"><ul><li>autoHide</li>
32 * <li>cls</li>
33 * <li>dismissDelay (overrides singleton value)</li>
34 * <li>target (required)</li>
35 * <li>text (required)</li>
36 * <li>title</li>
37 * <li>width</li></ul></div>
38 * <p>Here is an example showing how some of these config options could be used:</p>
39 * <pre><code>
40// Init the singleton.  Any tag-based quick tips will start working.
41Ext.QuickTips.init();
42
43// Apply a set of config properties to the singleton
44Ext.apply(Ext.QuickTips.getQuickTip(), {
45    maxWidth: 200,
46    minWidth: 100,
47    showDelay: 50,
48    trackMouse: true
49});
50
51// Manually register a quick tip for a specific element
52Ext.QuickTips.register({
53    target: 'my-div',
54    title: 'My Tooltip',
55    text: 'This tooltip was added in code',
56    width: 100,
57    dismissDelay: 20
58});
59</code></pre>
60 * <p>To register a quick tip in markup, you simply add one or more of the valid QuickTip attributes prefixed with
61 * the <b>ext:</b> namespace.  The HTML element itself is automatically set as the quick tip target. Here is the summary
62 * of supported attributes (optional unless otherwise noted):</p>
63 * <ul><li><b>hide</b>: Specifying "user" is equivalent to setting autoHide = false.  Any other value will be the
64 * same as autoHide = true.</li>
65 * <li><b>qclass</b>: A CSS class to be applied to the quick tip (equivalent to the 'cls' target element config).</li>
66 * <li><b>qtip (required)</b>: The quick tip text (equivalent to the 'text' target element config).</li>
67 * <li><b>qtitle</b>: The quick tip title (equivalent to the 'title' target element config).</li>
68 * <li><b>qwidth</b>: The quick tip width (equivalent to the 'width' target element config).</li></ul>
69 * <p>Here is an example of configuring an HTML element to display a tooltip from markup:</p>
70 * <pre><code>
71// Add a quick tip to an HTML button
72&lt;input type="button" value="OK" ext:qtitle="OK Button" ext:qwidth="100"
73     ext:qtip="This is a quick tip from markup!">&lt;/input>
74</code></pre>
75 * @singleton
76 */
77Ext.QuickTips = function(){
78    var tip, locks = [];
79    return {
80        /**
81         * Initialize the global QuickTips instance and prepare any quick tips.
82         * @param {Boolean} autoRender True to render the QuickTips container immediately to preload images. (Defaults to true)
83         */
84        init : function(autoRender){
85                    if(!tip){
86                        if(!Ext.isReady){
87                            Ext.onReady(function(){
88                                Ext.QuickTips.init(autoRender);
89                            });
90                            return;
91                        }
92                        tip = new Ext.QuickTip({elements:'header,body'});
93                        if(autoRender !== false){
94                            tip.render(Ext.getBody());
95                        }
96                    }
97        },
98
99        /**
100         * Enable quick tips globally.
101         */
102        enable : function(){
103            if(tip){
104                locks.pop();
105                if(locks.length < 1){
106                    tip.enable();
107                }
108            }
109        },
110
111        /**
112         * Disable quick tips globally.
113         */
114        disable : function(){
115            if(tip){
116                tip.disable();
117            }
118            locks.push(1);
119        },
120
121        /**
122         * Returns true if quick tips are enabled, else false.
123         * @return {Boolean}
124         */
125        isEnabled : function(){
126            return tip !== undefined && !tip.disabled;
127        },
128
129        /**
130         * Gets the global QuickTips instance.
131         */
132        getQuickTip : function(){
133            return tip;
134        },
135
136        /**
137         * Configures a new quick tip instance and assigns it to a target element.  See
138         * {@link Ext.QuickTip#register} for details.
139         * @param {Object} config The config object
140         */
141        register : function(){
142            tip.register.apply(tip, arguments);
143        },
144
145        /**
146         * Removes any registered quick tip from the target element and destroys it.
147         * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
148         */
149        unregister : function(){
150            tip.unregister.apply(tip, arguments);
151        },
152
153        /**
154         * Alias of {@link #register}.
155         * @param {Object} config The config object
156         */
157        tips :function(){
158            tip.register.apply(tip, arguments);
159        }
160    }
161}();
Note: See TracBrowser for help on using the repository browser.