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