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.

216 lines
7.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-Shadow-method-constructor'><span id='Ext-Shadow'>/**
  19. </span></span> * @class Ext.Shadow
  20. * Simple class that can provide a shadow effect for any element. Note that the element MUST be absolutely positioned,
  21. * and the shadow does not provide any shimming. This should be used only in simple cases -- for more advanced
  22. * functionality that can also provide the same shadow effect, see the {@link Ext.Layer} class.
  23. * @constructor
  24. * Create a new Shadow
  25. * @param {Object} config The config object
  26. */
  27. Ext.Shadow = function(config) {
  28. Ext.apply(this, config);
  29. if (typeof this.mode != &quot;string&quot;) {
  30. this.mode = this.defaultMode;
  31. }
  32. var o = this.offset,
  33. a = {
  34. h: 0
  35. },
  36. rad = Math.floor(this.offset / 2);
  37. switch (this.mode.toLowerCase()) {
  38. // all this hideous nonsense calculates the various offsets for shadows
  39. case &quot;drop&quot;:
  40. a.w = 0;
  41. a.l = a.t = o;
  42. a.t -= 1;
  43. if (Ext.isIE9m) {
  44. a.l -= this.offset + rad;
  45. a.t -= this.offset + rad;
  46. a.w -= rad;
  47. a.h -= rad;
  48. a.t += 1;
  49. }
  50. break;
  51. case &quot;sides&quot;:
  52. a.w = (o * 2);
  53. a.l = -o;
  54. a.t = o - 1;
  55. if (Ext.isIE9m) {
  56. a.l -= (this.offset - rad);
  57. a.t -= this.offset + rad;
  58. a.l += 1;
  59. a.w -= (this.offset - rad) * 2;
  60. a.w -= rad + 1;
  61. a.h -= 1;
  62. }
  63. break;
  64. case &quot;frame&quot;:
  65. a.w = a.h = (o * 2);
  66. a.l = a.t = -o;
  67. a.t += 1;
  68. a.h -= 2;
  69. if (Ext.isIE9m) {
  70. a.l -= (this.offset - rad);
  71. a.t -= (this.offset - rad);
  72. a.l += 1;
  73. a.w -= (this.offset + rad + 1);
  74. a.h -= (this.offset + rad);
  75. a.h += 1;
  76. }
  77. break;
  78. };
  79. this.adjusts = a;
  80. };
  81. Ext.Shadow.prototype = {
  82. <span id='Ext-Shadow-cfg-mode'> /**
  83. </span> * @cfg {String} mode
  84. * The shadow display mode. Supports the following options:&lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  85. * &lt;li&gt;&lt;b&gt;&lt;tt&gt;sides&lt;/tt&gt;&lt;/b&gt; : Shadow displays on both sides and bottom only&lt;/li&gt;
  86. * &lt;li&gt;&lt;b&gt;&lt;tt&gt;frame&lt;/tt&gt;&lt;/b&gt; : Shadow displays equally on all four sides&lt;/li&gt;
  87. * &lt;li&gt;&lt;b&gt;&lt;tt&gt;drop&lt;/tt&gt;&lt;/b&gt; : Traditional bottom-right drop shadow&lt;/li&gt;
  88. * &lt;/ul&gt;&lt;/div&gt;
  89. */
  90. <span id='Ext-Shadow-cfg-offset'> /**
  91. </span> * @cfg {String} offset
  92. * The number of pixels to offset the shadow from the element (defaults to &lt;tt&gt;4&lt;/tt&gt;)
  93. */
  94. offset: 4,
  95. // private
  96. defaultMode: &quot;drop&quot;,
  97. <span id='Ext-Shadow-method-show'> /**
  98. </span> * Displays the shadow under the target element
  99. * @param {Mixed} targetEl The id or element under which the shadow should display
  100. */
  101. show: function(target) {
  102. target = Ext.get(target);
  103. if (!this.el) {
  104. this.el = Ext.Shadow.Pool.pull();
  105. if (this.el.dom.nextSibling != target.dom) {
  106. this.el.insertBefore(target);
  107. }
  108. }
  109. this.el.setStyle(&quot;z-index&quot;, this.zIndex || parseInt(target.getStyle(&quot;z-index&quot;), 10) - 1);
  110. if (Ext.isIE9m) {
  111. this.el.dom.style.filter = &quot;progid:DXImageTransform.Microsoft.alpha(opacity=50) progid:DXImageTransform.Microsoft.Blur(pixelradius=&quot; + (this.offset) + &quot;)&quot;;
  112. }
  113. this.realign(
  114. target.getLeft(true),
  115. target.getTop(true),
  116. target.getWidth(),
  117. target.getHeight()
  118. );
  119. this.el.dom.style.display = &quot;block&quot;;
  120. },
  121. <span id='Ext-Shadow-method-isVisible'> /**
  122. </span> * Returns true if the shadow is visible, else false
  123. */
  124. isVisible: function() {
  125. return this.el ? true: false;
  126. },
  127. <span id='Ext-Shadow-method-realign'> /**
  128. </span> * Direct alignment when values are already available. Show must be called at least once before
  129. * calling this method to ensure it is initialized.
  130. * @param {Number} left The target element left position
  131. * @param {Number} top The target element top position
  132. * @param {Number} width The target element width
  133. * @param {Number} height The target element height
  134. */
  135. realign: function(l, t, w, h) {
  136. if (!this.el) {
  137. return;
  138. }
  139. var a = this.adjusts,
  140. d = this.el.dom,
  141. s = d.style,
  142. iea = 0,
  143. sw = (w + a.w),
  144. sh = (h + a.h),
  145. sws = sw + &quot;px&quot;,
  146. shs = sh + &quot;px&quot;,
  147. cn,
  148. sww;
  149. s.left = (l + a.l) + &quot;px&quot;;
  150. s.top = (t + a.t) + &quot;px&quot;;
  151. if (s.width != sws || s.height != shs) {
  152. s.width = sws;
  153. s.height = shs;
  154. if (!Ext.isIE9m) {
  155. cn = d.childNodes;
  156. sww = Math.max(0, (sw - 12)) + &quot;px&quot;;
  157. cn[0].childNodes[1].style.width = sww;
  158. cn[1].childNodes[1].style.width = sww;
  159. cn[2].childNodes[1].style.width = sww;
  160. cn[1].style.height = Math.max(0, (sh - 12)) + &quot;px&quot;;
  161. }
  162. }
  163. },
  164. <span id='Ext-Shadow-method-hide'> /**
  165. </span> * Hides this shadow
  166. */
  167. hide: function() {
  168. if (this.el) {
  169. this.el.dom.style.display = &quot;none&quot;;
  170. Ext.Shadow.Pool.push(this.el);
  171. delete this.el;
  172. }
  173. },
  174. <span id='Ext-Shadow-method-setZIndex'> /**
  175. </span> * Adjust the z-index of this shadow
  176. * @param {Number} zindex The new z-index
  177. */
  178. setZIndex: function(z) {
  179. this.zIndex = z;
  180. if (this.el) {
  181. this.el.setStyle(&quot;z-index&quot;, z);
  182. }
  183. }
  184. };
  185. // Private utility class that manages the internal Shadow cache
  186. Ext.Shadow.Pool = function() {
  187. var p = [],
  188. markup = Ext.isIE9m ?
  189. '&lt;div class=&quot;x-ie-shadow&quot;&gt;&lt;/div&gt;':
  190. '&lt;div class=&quot;x-shadow&quot;&gt;&lt;div class=&quot;xst&quot;&gt;&lt;div class=&quot;xstl&quot;&gt;&lt;/div&gt;&lt;div class=&quot;xstc&quot;&gt;&lt;/div&gt;&lt;div class=&quot;xstr&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;xsc&quot;&gt;&lt;div class=&quot;xsml&quot;&gt;&lt;/div&gt;&lt;div class=&quot;xsmc&quot;&gt;&lt;/div&gt;&lt;div class=&quot;xsmr&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;xsb&quot;&gt;&lt;div class=&quot;xsbl&quot;&gt;&lt;/div&gt;&lt;div class=&quot;xsbc&quot;&gt;&lt;/div&gt;&lt;div class=&quot;xsbr&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;';
  191. return {
  192. pull: function() {
  193. var sh = p.shift();
  194. if (!sh) {
  195. sh = Ext.get(Ext.DomHelper.insertHtml(&quot;beforeBegin&quot;, document.body.firstChild, markup));
  196. sh.autoBoxAdjust = false;
  197. }
  198. return sh;
  199. },
  200. push: function(sh) {
  201. p.push(sh);
  202. }
  203. };
  204. }();</pre>
  205. </body>
  206. </html>