4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-tip-QuickTipManager'>/**
19 </span> * @class Ext.tip.QuickTipManager
21 * Provides attractive and customizable tooltips for any element. The QuickTips
22 * singleton is used to configure and manage tooltips globally for multiple elements
23 * in a generic manner. To create individual tooltips with maximum customizability,
24 * you should consider either {@link Ext.tip.Tip} or {@link Ext.tip.ToolTip}.
26 * Quicktips can be configured via tag attributes directly in markup, or by
27 * registering quick tips programmatically via the {@link #register} method.
29 * The singleton's instance of {@link Ext.tip.QuickTip} is available via
30 * {@link #getQuickTip}, and supports all the methods, and all the all the
31 * configuration properties of Ext.tip.QuickTip. These settings will apply to all
32 * tooltips shown by the singleton.
34 * Below is the summary of the configuration properties which can be used.
35 * For detailed descriptions see the config options for the {@link Ext.tip.QuickTip QuickTip} class
37 * ## QuickTips singleton configs (all are optional)
46 * ## Target element configs (optional unless otherwise noted)
50 * - `dismissDelay` (overrides singleton value)
51 * - `target` (required)
56 * Here is an example showing how some of these config options could be used:
58 * {@img Ext.tip.QuickTipManager/Ext.tip.QuickTipManager.png Ext.tip.QuickTipManager component}
62 * // Init the singleton. Any tag-based quick tips will start working.
63 * Ext.tip.QuickTipManager.init();
65 * // Apply a set of config properties to the singleton
66 * Ext.apply(Ext.tip.QuickTipManager.getQuickTip(), {
69 * showDelay: 50 // Show 50ms after entering target
72 * // Create a small panel to add a quick tip to
73 * Ext.create('Ext.container.Container', {
74 * id: 'quickTipContainer',
78 * backgroundColor:'#000000'
80 * renderTo: Ext.getBody()
84 * // Manually register a quick tip for a specific element
85 * Ext.tip.QuickTipManager.register({
86 * target: 'quickTipContainer',
87 * title: 'My Tooltip',
88 * text: 'This tooltip was added in code',
90 * dismissDelay: 10000 // Hide after 10 seconds hover
93 * To register a quick tip in markup, you simply add one or more of the valid QuickTip attributes prefixed with
94 * the **data-** namespace. The HTML element itself is automatically set as the quick tip target. Here is the summary
95 * of supported attributes (optional unless otherwise noted):
97 * - `hide`: Specifying "user" is equivalent to setting autoHide = false. Any other value will be the same as autoHide = true.
98 * - `qclass`: A CSS class to be applied to the quick tip (equivalent to the 'cls' target element config).
99 * - `qtip (required)`: The quick tip text (equivalent to the 'text' target element config).
100 * - `qtitle`: The quick tip title (equivalent to the 'title' target element config).
101 * - `qwidth`: The quick tip width (equivalent to the 'width' target element config).
103 * Here is an example of configuring an HTML element to display a tooltip from markup:
105 * // Add a quick tip to an HTML button
106 * <input type="button" value="OK" data-qtitle="OK Button" data-qwidth="100"
107 * data-qtip="This is a quick tip from markup!"></input>
111 Ext.define('Ext.tip.QuickTipManager', function() {
116 requires: ['Ext.tip.QuickTip'],
118 alternateClassName: 'Ext.QuickTips',
120 <span id='Ext-tip-QuickTipManager-method-init'> /**
121 </span> * Initialize the global QuickTips instance and prepare any quick tips.
122 * @param {Boolean} autoRender True to render the QuickTips container immediately to
123 * preload images. (Defaults to true)
124 * @param {Object} config An optional config object for the created QuickTip. By
125 * default, the {@link Ext.tip.QuickTip QuickTip} class is instantiated, but this can
126 * be changed by supplying an xtype property or a className property in this object.
127 * All other properties on this object are configuration for the created component.
129 init : function (autoRender, config) {
132 Ext.onReady(function(){
133 Ext.tip.QuickTipManager.init(autoRender);
138 var tipConfig = Ext.apply({ disabled: disabled }, config),
139 className = tipConfig.className,
140 xtype = tipConfig.xtype;
143 delete tipConfig.className;
145 className = 'widget.' + xtype;
146 delete tipConfig.xtype;
149 if (autoRender !== false) {
150 tipConfig.renderTo = document.body;
153 if (tipConfig.renderTo.tagName != 'BODY') { // e.g., == 'FRAMESET'
155 sourceClass: 'Ext.tip.QuickTipManager',
156 sourceMethod: 'init',
157 msg: 'Cannot init QuickTipManager: no document body'
163 tip = Ext.create(className || 'Ext.tip.QuickTip', tipConfig);
167 <span id='Ext-tip-QuickTipManager-method-destroy'> /**
168 </span> * Destroy the QuickTips instance.
170 destroy: function() {
178 // Protected method called by the dd classes
179 ddDisable : function(){
180 // don't disable it if we don't need to
181 if(tip && !disabled){
186 // Protected method called by the dd classes
187 ddEnable : function(){
188 // only enable it if it hasn't been disabled
189 if(tip && !disabled){
194 <span id='Ext-tip-QuickTipManager-method-enable'> /**
195 </span> * Enable quick tips globally.
204 <span id='Ext-tip-QuickTipManager-method-disable'> /**
205 </span> * Disable quick tips globally.
207 disable : function(){
214 <span id='Ext-tip-QuickTipManager-method-isEnabled'> /**
215 </span> * Returns true if quick tips are enabled, else false.
218 isEnabled : function(){
219 return tip !== undefined && !tip.disabled;
222 <span id='Ext-tip-QuickTipManager-method-getQuickTip'> /**
223 </span> * Gets the single {@link Ext.tip.QuickTip QuickTip} instance used to show tips from all registered elements.
224 * @return {Ext.tip.QuickTip}
226 getQuickTip : function(){
230 <span id='Ext-tip-QuickTipManager-method-register'> /**
231 </span> * Configures a new quick tip instance and assigns it to a target element. See
232 * {@link Ext.tip.QuickTip#register} for details.
233 * @param {Object} config The config object
235 register : function(){
236 tip.register.apply(tip, arguments);
239 <span id='Ext-tip-QuickTipManager-method-unregister'> /**
240 </span> * Removes any registered quick tip from the target element and destroys it.
241 * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
243 unregister : function(){
244 tip.unregister.apply(tip, arguments);
247 <span id='Ext-tip-QuickTipManager-method-tips'> /**
248 </span> * Alias of {@link #register}.
249 * @param {Object} config The config object
252 tip.register.apply(tip, arguments);