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.

174 lines
6.8 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-Tip-method-constructor'><span id='Ext-Tip'>/**
  19. </span></span> * @class Ext.Tip
  20. * @extends Ext.Panel
  21. * @xtype tip
  22. * This is the base class for {@link Ext.QuickTip} and {@link Ext.Tooltip} that provides the basic layout and
  23. * positioning that all tip-based classes require. This class can be used directly for simple, statically-positioned
  24. * tips that are displayed programmatically, or it can be extended to provide custom tip implementations.
  25. * @constructor
  26. * Create a new Tip
  27. * @param {Object} config The configuration options
  28. */
  29. Ext.Tip = Ext.extend(Ext.Panel, {
  30. <span id='Ext-Tip-cfg-closable'> /**
  31. </span> * @cfg {Boolean} closable True to render a close tool button into the tooltip header (defaults to false).
  32. */
  33. <span id='Ext-Tip-cfg-width'> /**
  34. </span> * @cfg {Number} width
  35. * Width in pixels of the tip (defaults to auto). Width will be ignored if it exceeds the bounds of
  36. * {@link #minWidth} or {@link #maxWidth}. The maximum supported value is 500.
  37. */
  38. <span id='Ext-Tip-cfg-minWidth'> /**
  39. </span> * @cfg {Number} minWidth The minimum width of the tip in pixels (defaults to 40).
  40. */
  41. minWidth : 40,
  42. <span id='Ext-Tip-cfg-maxWidth'> /**
  43. </span> * @cfg {Number} maxWidth The maximum width of the tip in pixels (defaults to 300). The maximum supported value is 500.
  44. */
  45. maxWidth : 300,
  46. <span id='Ext-Tip-cfg-shadow'> /**
  47. </span> * @cfg {Boolean/String} shadow True or &quot;sides&quot; for the default effect, &quot;frame&quot; for 4-way shadow, and &quot;drop&quot;
  48. * for bottom-right shadow (defaults to &quot;sides&quot;).
  49. */
  50. shadow : &quot;sides&quot;,
  51. <span id='Ext-Tip-cfg-defaultAlign'> /**
  52. </span> * @cfg {String} defaultAlign &lt;b&gt;Experimental&lt;/b&gt;. The default {@link Ext.Element#alignTo} anchor position value
  53. * for this tip relative to its element of origin (defaults to &quot;tl-bl?&quot;).
  54. */
  55. defaultAlign : &quot;tl-bl?&quot;,
  56. <span id='Ext-Tip-property-autoRender'> autoRender: true,
  57. </span><span id='Ext-Tip-property-quickShowInterval'> quickShowInterval : 250,
  58. </span>
  59. <span id='Ext-Tip-cfg-frame'> // private panel overrides
  60. </span> frame:true,
  61. <span id='Ext-Tip-property-hidden'> hidden:true,
  62. </span><span id='Ext-Tip-cfg-baseCls'> baseCls: 'x-tip',
  63. </span><span id='Ext-Tip-cfg-floating'> floating:{shadow:true,shim:true,useDisplay:true,constrain:false},
  64. </span><span id='Ext-Tip-cfg-autoHeight'> autoHeight:true,
  65. </span>
  66. <span id='Ext-Tip-property-closeAction'> closeAction: 'hide',
  67. </span>
  68. <span id='Ext-Tip-method-initComponent'> // private
  69. </span> initComponent : function(){
  70. Ext.Tip.superclass.initComponent.call(this);
  71. if(this.closable &amp;&amp; !this.title){
  72. this.elements += ',header';
  73. }
  74. },
  75. <span id='Ext-Tip-method-afterRender'> // private
  76. </span> afterRender : function(){
  77. Ext.Tip.superclass.afterRender.call(this);
  78. if(this.closable){
  79. this.addTool({
  80. id: 'close',
  81. handler: this[this.closeAction],
  82. scope: this
  83. });
  84. }
  85. },
  86. <span id='Ext-Tip-method-showAt'> /**
  87. </span> * Shows this tip at the specified XY position. Example usage:
  88. * &lt;pre&gt;&lt;code&gt;
  89. // Show the tip at x:50 and y:100
  90. tip.showAt([50,100]);
  91. &lt;/code&gt;&lt;/pre&gt;
  92. * @param {Array} xy An array containing the x and y coordinates
  93. */
  94. showAt : function(xy){
  95. Ext.Tip.superclass.show.call(this);
  96. if(this.measureWidth !== false &amp;&amp; (!this.initialConfig || typeof this.initialConfig.width != 'number')){
  97. this.doAutoWidth();
  98. }
  99. if(this.constrainPosition){
  100. xy = this.el.adjustForConstraints(xy);
  101. }
  102. this.setPagePosition(xy[0], xy[1]);
  103. },
  104. <span id='Ext-Tip-method-doAutoWidth'> // protected
  105. </span> doAutoWidth : function(adjust){
  106. adjust = adjust || 0;
  107. var bw = this.body.getTextWidth();
  108. if(this.title){
  109. bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));
  110. }
  111. bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding(&quot;lr&quot;) + adjust;
  112. this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
  113. // IE7 repaint bug on initial show
  114. if(Ext.isIE7 &amp;&amp; !this.repainted){
  115. this.el.repaint();
  116. this.repainted = true;
  117. }
  118. },
  119. <span id='Ext-Tip-method-showBy'> /**
  120. </span> * &lt;b&gt;Experimental&lt;/b&gt;. Shows this tip at a position relative to another element using a standard {@link Ext.Element#alignTo}
  121. * anchor position value. Example usage:
  122. * &lt;pre&gt;&lt;code&gt;
  123. // Show the tip at the default position ('tl-br?')
  124. tip.showBy('my-el');
  125. // Show the tip's top-left corner anchored to the element's top-right corner
  126. tip.showBy('my-el', 'tl-tr');
  127. &lt;/code&gt;&lt;/pre&gt;
  128. * @param {Mixed} el An HTMLElement, Ext.Element or string id of the target element to align to
  129. * @param {String} position (optional) A valid {@link Ext.Element#alignTo} anchor position (defaults to 'tl-br?' or
  130. * {@link #defaultAlign} if specified).
  131. */
  132. showBy : function(el, pos){
  133. if(!this.rendered){
  134. this.render(Ext.getBody());
  135. }
  136. this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
  137. },
  138. <span id='Ext-Tip-method-initDraggable'> initDraggable : function(){
  139. </span> this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
  140. this.header.addClass('x-tip-draggable');
  141. }
  142. });
  143. Ext.reg('tip', Ext.Tip);
  144. // private - custom Tip DD implementation
  145. Ext.Tip.DD = function(tip, config){
  146. Ext.apply(this, config);
  147. this.tip = tip;
  148. Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id);
  149. this.setHandleElId(tip.header.id);
  150. this.scroll = false;
  151. };
  152. Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
  153. moveOnly:true,
  154. scroll:false,
  155. headerOffsets:[100, 25],
  156. startDrag : function(){
  157. this.tip.el.disableShadow();
  158. },
  159. endDrag : function(e){
  160. this.tip.el.enableShadow(true);
  161. }
  162. });</pre>
  163. </body>
  164. </html>