You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

192 lines
7.9 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-QuickTips'>/**
  19. </span> * @class Ext.QuickTips
  20. * &lt;p&gt;Provides attractive and customizable tooltips for any element. The QuickTips
  21. * singleton is used to configure and manage tooltips globally for multiple elements
  22. * in a generic manner. To create individual tooltips with maximum customizability,
  23. * you should consider either {@link Ext.Tip} or {@link Ext.ToolTip}.&lt;/p&gt;
  24. * &lt;p&gt;Quicktips can be configured via tag attributes directly in markup, or by
  25. * registering quick tips programmatically via the {@link #register} method.&lt;/p&gt;
  26. * &lt;p&gt;The singleton's instance of {@link Ext.QuickTip} is available via
  27. * {@link #getQuickTip}, and supports all the methods, and all the all the
  28. * configuration properties of Ext.QuickTip. These settings will apply to all
  29. * tooltips shown by the singleton.&lt;/p&gt;
  30. * &lt;p&gt;Below is the summary of the configuration properties which can be used.
  31. * For detailed descriptions see the config options for the {@link Ext.QuickTip QuickTip} class&lt;/p&gt;
  32. * &lt;p&gt;&lt;b&gt;QuickTips singleton configs (all are optional)&lt;/b&gt;&lt;/p&gt;
  33. * &lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;&lt;li&gt;dismissDelay&lt;/li&gt;
  34. * &lt;li&gt;hideDelay&lt;/li&gt;
  35. * &lt;li&gt;maxWidth&lt;/li&gt;
  36. * &lt;li&gt;minWidth&lt;/li&gt;
  37. * &lt;li&gt;showDelay&lt;/li&gt;
  38. * &lt;li&gt;trackMouse&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;
  39. * &lt;p&gt;&lt;b&gt;Target element configs (optional unless otherwise noted)&lt;/b&gt;&lt;/p&gt;
  40. * &lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;&lt;li&gt;autoHide&lt;/li&gt;
  41. * &lt;li&gt;cls&lt;/li&gt;
  42. * &lt;li&gt;dismissDelay (overrides singleton value)&lt;/li&gt;
  43. * &lt;li&gt;target (required)&lt;/li&gt;
  44. * &lt;li&gt;text (required)&lt;/li&gt;
  45. * &lt;li&gt;title&lt;/li&gt;
  46. * &lt;li&gt;width&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;
  47. * &lt;p&gt;Here is an example showing how some of these config options could be used:&lt;/p&gt;
  48. * &lt;pre&gt;&lt;code&gt;
  49. // Init the singleton. Any tag-based quick tips will start working.
  50. Ext.QuickTips.init();
  51. // Apply a set of config properties to the singleton
  52. Ext.apply(Ext.QuickTips.getQuickTip(), {
  53. maxWidth: 200,
  54. minWidth: 100,
  55. showDelay: 50, // Show 50ms after entering target
  56. trackMouse: true
  57. });
  58. // Manually register a quick tip for a specific element
  59. Ext.QuickTips.register({
  60. target: 'my-div',
  61. title: 'My Tooltip',
  62. text: 'This tooltip was added in code',
  63. width: 100,
  64. dismissDelay: 10000 // Hide after 10 seconds hover
  65. });
  66. &lt;/code&gt;&lt;/pre&gt;
  67. * &lt;p&gt;To register a quick tip in markup, you simply add one or more of the valid QuickTip attributes prefixed with
  68. * the &lt;b&gt;ext:&lt;/b&gt; namespace. The HTML element itself is automatically set as the quick tip target. Here is the summary
  69. * of supported attributes (optional unless otherwise noted):&lt;/p&gt;
  70. * &lt;ul&gt;&lt;li&gt;&lt;b&gt;hide&lt;/b&gt;: Specifying &quot;user&quot; is equivalent to setting autoHide = false. Any other value will be the
  71. * same as autoHide = true.&lt;/li&gt;
  72. * &lt;li&gt;&lt;b&gt;qclass&lt;/b&gt;: A CSS class to be applied to the quick tip (equivalent to the 'cls' target element config).&lt;/li&gt;
  73. * &lt;li&gt;&lt;b&gt;qtip (required)&lt;/b&gt;: The quick tip text (equivalent to the 'text' target element config).&lt;/li&gt;
  74. * &lt;li&gt;&lt;b&gt;qtitle&lt;/b&gt;: The quick tip title (equivalent to the 'title' target element config).&lt;/li&gt;
  75. * &lt;li&gt;&lt;b&gt;qwidth&lt;/b&gt;: The quick tip width (equivalent to the 'width' target element config).&lt;/li&gt;&lt;/ul&gt;
  76. * &lt;p&gt;Here is an example of configuring an HTML element to display a tooltip from markup:&lt;/p&gt;
  77. * &lt;pre&gt;&lt;code&gt;
  78. // Add a quick tip to an HTML button
  79. &amp;lt;input type=&quot;button&quot; value=&quot;OK&quot; ext:qtitle=&quot;OK Button&quot; ext:qwidth=&quot;100&quot;
  80. ext:qtip=&quot;This is a quick tip from markup!&quot;&gt;&amp;lt;/input&gt;
  81. &lt;/code&gt;&lt;/pre&gt;
  82. * @singleton
  83. */
  84. Ext.QuickTips = function(){
  85. var tip,
  86. disabled = false;
  87. return {
  88. <span id='Ext-QuickTips-method-init'> /**
  89. </span> * Initialize the global QuickTips instance and prepare any quick tips.
  90. * @param {Boolean} autoRender True to render the QuickTips container immediately to preload images. (Defaults to true)
  91. */
  92. init : function(autoRender){
  93. if(!tip){
  94. if(!Ext.isReady){
  95. Ext.onReady(function(){
  96. Ext.QuickTips.init(autoRender);
  97. });
  98. return;
  99. }
  100. tip = new Ext.QuickTip({
  101. elements:'header,body',
  102. disabled: disabled
  103. });
  104. if(autoRender !== false){
  105. tip.render(Ext.getBody());
  106. }
  107. }
  108. },
  109. // Protected method called by the dd classes
  110. ddDisable : function(){
  111. // don't disable it if we don't need to
  112. if(tip &amp;&amp; !disabled){
  113. tip.disable();
  114. }
  115. },
  116. // Protected method called by the dd classes
  117. ddEnable : function(){
  118. // only enable it if it hasn't been disabled
  119. if(tip &amp;&amp; !disabled){
  120. tip.enable();
  121. }
  122. },
  123. <span id='Ext-QuickTips-method-enable'> /**
  124. </span> * Enable quick tips globally.
  125. */
  126. enable : function(){
  127. if(tip){
  128. tip.enable();
  129. }
  130. disabled = false;
  131. },
  132. <span id='Ext-QuickTips-method-disable'> /**
  133. </span> * Disable quick tips globally.
  134. */
  135. disable : function(){
  136. if(tip){
  137. tip.disable();
  138. }
  139. disabled = true;
  140. },
  141. <span id='Ext-QuickTips-method-isEnabled'> /**
  142. </span> * Returns true if quick tips are enabled, else false.
  143. * @return {Boolean}
  144. */
  145. isEnabled : function(){
  146. return tip !== undefined &amp;&amp; !tip.disabled;
  147. },
  148. <span id='Ext-QuickTips-method-getQuickTip'> /**
  149. </span> * Gets the single {@link Ext.QuickTip QuickTip} instance used to show tips from all registered elements.
  150. * @return {Ext.QuickTip}
  151. */
  152. getQuickTip : function(){
  153. return tip;
  154. },
  155. <span id='Ext-QuickTips-method-register'> /**
  156. </span> * Configures a new quick tip instance and assigns it to a target element. See
  157. * {@link Ext.QuickTip#register} for details.
  158. * @param {Object} config The config object
  159. */
  160. register : function(){
  161. tip.register.apply(tip, arguments);
  162. },
  163. <span id='Ext-QuickTips-method-unregister'> /**
  164. </span> * Removes any registered quick tip from the target element and destroys it.
  165. * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
  166. */
  167. unregister : function(){
  168. tip.unregister.apply(tip, arguments);
  169. },
  170. <span id='Ext-QuickTips-method-tips'> /**
  171. </span> * Alias of {@link #register}.
  172. * @param {Object} config The config object
  173. */
  174. tips : function(){
  175. tip.register.apply(tip, arguments);
  176. }
  177. };
  178. }();</pre>
  179. </body>
  180. </html>