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.

234 lines
8.4 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-QuickTip-method-constructor'><span id='Ext-QuickTip'>/**
  19. </span></span> * @class Ext.QuickTip
  20. * @extends Ext.ToolTip
  21. * @xtype quicktip
  22. * A specialized tooltip class for tooltips that can be specified in markup and automatically managed by the global
  23. * {@link Ext.QuickTips} instance. See the QuickTips class header for additional usage details and examples.
  24. * @constructor
  25. * Create a new Tip
  26. * @param {Object} config The configuration options
  27. */
  28. Ext.QuickTip = Ext.extend(Ext.ToolTip, {
  29. <span id='Ext-QuickTip-cfg-target'> /**
  30. </span> * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to associate with this quicktip (defaults to the document).
  31. */
  32. <span id='Ext-QuickTip-cfg-interceptTitles'> /**
  33. </span> * @cfg {Boolean} interceptTitles True to automatically use the element's DOM title value if available (defaults to false).
  34. */
  35. interceptTitles : false,
  36. <span id='Ext-QuickTip-property-tagConfig'> // private
  37. </span> tagConfig : {
  38. namespace : &quot;ext&quot;,
  39. attribute : &quot;qtip&quot;,
  40. width : &quot;qwidth&quot;,
  41. target : &quot;target&quot;,
  42. title : &quot;qtitle&quot;,
  43. hide : &quot;hide&quot;,
  44. cls : &quot;qclass&quot;,
  45. align : &quot;qalign&quot;,
  46. anchor : &quot;anchor&quot;
  47. },
  48. <span id='Ext-QuickTip-method-initComponent'> // private
  49. </span> initComponent : function(){
  50. this.target = this.target || Ext.getDoc();
  51. this.targets = this.targets || {};
  52. Ext.QuickTip.superclass.initComponent.call(this);
  53. },
  54. <span id='Ext-QuickTip-method-register'> /**
  55. </span> * Configures a new quick tip instance and assigns it to a target element. The following config values are
  56. * supported (for example usage, see the {@link Ext.QuickTips} class header):
  57. * &lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  58. * &lt;li&gt;autoHide&lt;/li&gt;
  59. * &lt;li&gt;cls&lt;/li&gt;
  60. * &lt;li&gt;dismissDelay (overrides the singleton value)&lt;/li&gt;
  61. * &lt;li&gt;target (required)&lt;/li&gt;
  62. * &lt;li&gt;text (required)&lt;/li&gt;
  63. * &lt;li&gt;title&lt;/li&gt;
  64. * &lt;li&gt;width&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;
  65. * @param {Object} config The config object
  66. */
  67. register : function(config){
  68. var cs = Ext.isArray(config) ? config : arguments;
  69. for(var i = 0, len = cs.length; i &lt; len; i++){
  70. var c = cs[i];
  71. var target = c.target;
  72. if(target){
  73. if(Ext.isArray(target)){
  74. for(var j = 0, jlen = target.length; j &lt; jlen; j++){
  75. this.targets[Ext.id(target[j])] = c;
  76. }
  77. } else{
  78. this.targets[Ext.id(target)] = c;
  79. }
  80. }
  81. }
  82. },
  83. <span id='Ext-QuickTip-method-unregister'> /**
  84. </span> * Removes this quick tip from its element and destroys it.
  85. * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
  86. */
  87. unregister : function(el){
  88. delete this.targets[Ext.id(el)];
  89. },
  90. <span id='Ext-QuickTip-method-cancelShow'> /**
  91. </span> * Hides a visible tip or cancels an impending show for a particular element.
  92. * @param {String/HTMLElement/Element} el The element that is the target of the tip.
  93. */
  94. cancelShow: function(el){
  95. var at = this.activeTarget;
  96. el = Ext.get(el).dom;
  97. if(this.isVisible()){
  98. if(at &amp;&amp; at.el == el){
  99. this.hide();
  100. }
  101. }else if(at &amp;&amp; at.el == el){
  102. this.clearTimer('show');
  103. }
  104. },
  105. <span id='Ext-QuickTip-method-getTipCfg'> getTipCfg: function(e) {
  106. </span> var t = e.getTarget(),
  107. ttp,
  108. cfg;
  109. if(this.interceptTitles &amp;&amp; t.title &amp;&amp; Ext.isString(t.title)){
  110. ttp = t.title;
  111. t.qtip = ttp;
  112. t.removeAttribute(&quot;title&quot;);
  113. e.preventDefault();
  114. }else{
  115. cfg = this.tagConfig;
  116. ttp = t.qtip || Ext.fly(t).getAttribute(cfg.attribute, cfg.namespace);
  117. }
  118. return ttp;
  119. },
  120. <span id='Ext-QuickTip-method-onTargetOver'> // private
  121. </span> onTargetOver : function(e){
  122. if(this.disabled){
  123. return;
  124. }
  125. this.targetXY = e.getXY();
  126. var t = e.getTarget();
  127. if(!t || t.nodeType !== 1 || t == document || t == document.body){
  128. return;
  129. }
  130. if(this.activeTarget &amp;&amp; ((t == this.activeTarget.el) || Ext.fly(this.activeTarget.el).contains(t))){
  131. this.clearTimer('hide');
  132. this.show();
  133. return;
  134. }
  135. if(t &amp;&amp; this.targets[t.id]){
  136. this.activeTarget = this.targets[t.id];
  137. this.activeTarget.el = t;
  138. this.anchor = this.activeTarget.anchor;
  139. if(this.anchor){
  140. this.anchorTarget = t;
  141. }
  142. this.delayShow();
  143. return;
  144. }
  145. var ttp, et = Ext.fly(t), cfg = this.tagConfig, ns = cfg.namespace;
  146. if(ttp = this.getTipCfg(e)){
  147. var autoHide = et.getAttribute(cfg.hide, ns);
  148. this.activeTarget = {
  149. el: t,
  150. text: ttp,
  151. width: et.getAttribute(cfg.width, ns),
  152. autoHide: autoHide != &quot;user&quot; &amp;&amp; autoHide !== 'false',
  153. title: et.getAttribute(cfg.title, ns),
  154. cls: et.getAttribute(cfg.cls, ns),
  155. align: et.getAttribute(cfg.align, ns)
  156. };
  157. this.anchor = et.getAttribute(cfg.anchor, ns);
  158. if(this.anchor){
  159. this.anchorTarget = t;
  160. }
  161. this.delayShow();
  162. }
  163. },
  164. <span id='Ext-QuickTip-method-onTargetOut'> // private
  165. </span> onTargetOut : function(e){
  166. // If moving within the current target, and it does not have a new tip, ignore the mouseout
  167. if (this.activeTarget &amp;&amp; e.within(this.activeTarget.el) &amp;&amp; !this.getTipCfg(e)) {
  168. return;
  169. }
  170. this.clearTimer('show');
  171. if(this.autoHide !== false){
  172. this.delayHide();
  173. }
  174. },
  175. <span id='Ext-QuickTip-method-showAt'> // inherit docs
  176. </span> showAt : function(xy){
  177. var t = this.activeTarget;
  178. if(t){
  179. if(!this.rendered){
  180. this.render(Ext.getBody());
  181. this.activeTarget = t;
  182. }
  183. if(t.width){
  184. this.setWidth(t.width);
  185. this.body.setWidth(this.adjustBodyWidth(t.width - this.getFrameWidth()));
  186. this.measureWidth = false;
  187. } else{
  188. this.measureWidth = true;
  189. }
  190. this.setTitle(t.title || '');
  191. this.body.update(t.text);
  192. this.autoHide = t.autoHide;
  193. this.dismissDelay = t.dismissDelay || this.dismissDelay;
  194. if(this.lastCls){
  195. this.el.removeClass(this.lastCls);
  196. delete this.lastCls;
  197. }
  198. if(t.cls){
  199. this.el.addClass(t.cls);
  200. this.lastCls = t.cls;
  201. }
  202. if(this.anchor){
  203. this.constrainPosition = false;
  204. }else if(t.align){ // TODO: this doesn't seem to work consistently
  205. xy = this.el.getAlignToXY(t.el, t.align);
  206. this.constrainPosition = false;
  207. }else{
  208. this.constrainPosition = true;
  209. }
  210. }
  211. Ext.QuickTip.superclass.showAt.call(this, xy);
  212. },
  213. <span id='Ext-QuickTip-method-hide'> // inherit docs
  214. </span> hide: function(){
  215. delete this.activeTarget;
  216. Ext.QuickTip.superclass.hide.call(this);
  217. }
  218. });
  219. Ext.reg('quicktip', Ext.QuickTip);</pre>
  220. </body>
  221. </html>