3
* Copyright(c) 2006-2008, Ext JS, LLC.
6
* http://extjs.com/license
11
* Simple class that can provide a shadow effect for any element. Note that the element MUST be absolutely positioned,
12
* and the shadow does not provide any shimming. This should be used only in simple cases -- for more advanced
13
* functionality that can also provide the same shadow effect, see the {@link Ext.Layer} class.
16
* @param {Object} config The config object
18
Ext.Shadow = function(config){
19
Ext.apply(this, config);
20
if(typeof this.mode != "string"){
21
this.mode = this.defaultMode;
23
var o = this.offset, a = {h: 0};
24
var rad = Math.floor(this.offset/2);
25
switch(this.mode.toLowerCase()){ // all this hideous nonsense calculates the various offsets for shadows
31
a.l -= this.offset + rad;
32
a.t -= this.offset + rad;
43
a.l -= (this.offset - rad);
44
a.t -= this.offset + rad;
46
a.w -= (this.offset - rad)*2;
57
a.l -= (this.offset - rad);
58
a.t -= (this.offset - rad);
60
a.w -= (this.offset + rad + 1);
61
a.h -= (this.offset + rad);
70
Ext.Shadow.prototype = {
73
* The shadow display mode. Supports the following options:<br />
74
* sides: Shadow displays on both sides and bottom only<br />
75
* frame: Shadow displays equally on all four sides<br />
76
* drop: Traditional bottom-right drop shadow (default)
79
* @cfg {String} offset
80
* The number of pixels to offset the shadow from the element (defaults to 4)
88
* Displays the shadow under the target element
89
* @param {Mixed} targetEl The id or element under which the shadow should display
91
show : function(target){
92
target = Ext.get(target);
94
this.el = Ext.Shadow.Pool.pull();
95
if(this.el.dom.nextSibling != target.dom){
96
this.el.insertBefore(target);
99
this.el.setStyle("z-index", this.zIndex || parseInt(target.getStyle("z-index"), 10)-1);
101
this.el.dom.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity=50) progid:DXImageTransform.Microsoft.Blur(pixelradius="+(this.offset)+")";
104
target.getLeft(true),
109
this.el.dom.style.display = "block";
113
* Returns true if the shadow is visible, else false
115
isVisible : function(){
116
return this.el ? true : false;
120
* Direct alignment when values are already available. Show must be called at least once before
121
* calling this method to ensure it is initialized.
122
* @param {Number} left The target element left position
123
* @param {Number} top The target element top position
124
* @param {Number} width The target element width
125
* @param {Number} height The target element height
127
realign : function(l, t, w, h){
131
var a = this.adjusts, d = this.el.dom, s = d.style;
133
s.left = (l+a.l)+"px";
134
s.top = (t+a.t)+"px";
135
var sw = (w+a.w), sh = (h+a.h), sws = sw +"px", shs = sh + "px";
136
if(s.width != sws || s.height != shs){
140
var cn = d.childNodes;
141
var sww = Math.max(0, (sw-12))+"px";
142
cn[0].childNodes[1].style.width = sww;
143
cn[1].childNodes[1].style.width = sww;
144
cn[2].childNodes[1].style.width = sww;
145
cn[1].style.height = Math.max(0, (sh-12))+"px";
155
this.el.dom.style.display = "none";
156
Ext.Shadow.Pool.push(this.el);
162
* Adjust the z-index of this shadow
163
* @param {Number} zindex The new z-index
165
setZIndex : function(z){
168
this.el.setStyle("z-index", z);
173
// Private utility class that manages the internal Shadow cache
174
Ext.Shadow.Pool = function(){
176
var markup = Ext.isIE ?
177
'<div class="x-ie-shadow"></div>' :
178
'<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>';
183
sh = Ext.get(Ext.DomHelper.insertHtml("beforeBegin", document.body.firstChild, markup));
184
sh.autoBoxAdjust = false;
b'\\ No newline at end of file'