3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.Shadow"></div>/**
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 = {
71 <div id="cfg-Ext.Shadow-mode"></div>/**
73 * The shadow display mode. Supports the following options:<div class="mdetail-params"><ul>
74 * <li><b><tt>sides</tt></b> : Shadow displays on both sides and bottom only</li>
75 * <li><b><tt>frame</tt></b> : Shadow displays equally on all four sides</li>
76 * <li><b><tt>drop</tt></b> : Traditional bottom-right drop shadow</li>
79 <div id="cfg-Ext.Shadow-offset"></div>/**
80 * @cfg {String} offset
81 * The number of pixels to offset the shadow from the element (defaults to <tt>4</tt>)
88 <div id="method-Ext.Shadow-show"></div>/**
89 * Displays the shadow under the target element
90 * @param {Mixed} targetEl The id or element under which the shadow should display
92 show : function(target){
93 target = Ext.get(target);
95 this.el = Ext.Shadow.Pool.pull();
96 if(this.el.dom.nextSibling != target.dom){
97 this.el.insertBefore(target);
100 this.el.setStyle("z-index", this.zIndex || parseInt(target.getStyle("z-index"), 10)-1);
102 this.el.dom.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity=50) progid:DXImageTransform.Microsoft.Blur(pixelradius="+(this.offset)+")";
105 target.getLeft(true),
110 this.el.dom.style.display = "block";
113 <div id="method-Ext.Shadow-isVisible"></div>/**
114 * Returns true if the shadow is visible, else false
116 isVisible : function(){
117 return this.el ? true : false;
120 <div id="method-Ext.Shadow-realign"></div>/**
121 * Direct alignment when values are already available. Show must be called at least once before
122 * calling this method to ensure it is initialized.
123 * @param {Number} left The target element left position
124 * @param {Number} top The target element top position
125 * @param {Number} width The target element width
126 * @param {Number} height The target element height
128 realign : function(l, t, w, h){
132 var a = this.adjusts, d = this.el.dom, s = d.style;
134 s.left = (l+a.l)+"px";
135 s.top = (t+a.t)+"px";
136 var sw = (w+a.w), sh = (h+a.h), sws = sw +"px", shs = sh + "px";
137 if(s.width != sws || s.height != shs){
141 var cn = d.childNodes;
142 var sww = Math.max(0, (sw-12))+"px";
143 cn[0].childNodes[1].style.width = sww;
144 cn[1].childNodes[1].style.width = sww;
145 cn[2].childNodes[1].style.width = sww;
146 cn[1].style.height = Math.max(0, (sh-12))+"px";
151 <div id="method-Ext.Shadow-hide"></div>/**
156 this.el.dom.style.display = "none";
157 Ext.Shadow.Pool.push(this.el);
162 <div id="method-Ext.Shadow-setZIndex"></div>/**
163 * Adjust the z-index of this shadow
164 * @param {Number} zindex The new z-index
166 setZIndex : function(z){
169 this.el.setStyle("z-index", z);
174 // Private utility class that manages the internal Shadow cache
175 Ext.Shadow.Pool = function(){
177 var markup = Ext.isIE ?
178 '<div class="x-ie-shadow"></div>' :
179 '<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>';
184 sh = Ext.get(Ext.DomHelper.insertHtml("beforeBegin", document.body.firstChild, markup));
185 sh.autoBoxAdjust = false;