Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / fx / Shadow.js @ 11

History | View | Annotate | Download (2.74 KB)

1
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6

    
7

    
8
if(!dojo._hasResource["dojox.fx.Shadow"]){
9
dojo._hasResource["dojox.fx.Shadow"]=true;
10
dojo.provide("dojox.fx.Shadow");
11
dojo.experimental("dojox.fx.Shadow");
12
dojo.require("dijit._Widget");
13
dojo.require("dojo.NodeList-fx");
14
dojo.declare("dojox.fx.Shadow",dijit._Widget,{shadowPng:dojo.moduleUrl("dojox.fx","resources/shadow"),shadowThickness:7,shadowOffset:3,opacity:0.75,animate:false,node:null,startup:function(){
15
this.inherited(arguments);
16
this.node.style.position="relative";
17
this.pieces={};
18
var x1=-1*this.shadowThickness;
19
var y0=this.shadowOffset;
20
var y1=this.shadowOffset+this.shadowThickness;
21
this._makePiece("tl","top",y0,"left",x1);
22
this._makePiece("l","top",y1,"left",x1,"scale");
23
this._makePiece("tr","top",y0,"left",0);
24
this._makePiece("r","top",y1,"left",0,"scale");
25
this._makePiece("bl","top",0,"left",x1);
26
this._makePiece("b","top",0,"left",0,"crop");
27
this._makePiece("br","top",0,"left",0);
28
this.nodeList=dojo.query(".shadowPiece",this.node);
29
this.setOpacity(this.opacity);
30
this.resize();
31
},_makePiece:function(_1,_2,_3,_4,_5,_6){
32
var _7;
33
var _8=this.shadowPng+_1.toUpperCase()+".png";
34
if(dojo.isIE<7){
35
_7=dojo.create("div");
36
_7.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+_8+"'"+(_6?", sizingMethod='"+_6+"'":"")+")";
37
}else{
38
_7=dojo.create("img",{src:_8});
39
}
40
_7.style.position="absolute";
41
_7.style[_2]=_3+"px";
42
_7.style[_4]=_5+"px";
43
_7.style.width=this.shadowThickness+"px";
44
_7.style.height=this.shadowThickness+"px";
45
dojo.addClass(_7,"shadowPiece");
46
this.pieces[_1]=_7;
47
this.node.appendChild(_7);
48
},setOpacity:function(n,_9){
49
if(dojo.isIE){
50
return;
51
}
52
if(!_9){
53
_9={};
54
}
55
if(this.animate){
56
var _a=[];
57
this.nodeList.forEach(function(_b){
58
_a.push(dojo._fade(dojo.mixin(_9,{node:_b,end:n})));
59
});
60
dojo.fx.combine(_a).play();
61
}else{
62
this.nodeList.style("opacity",n);
63
}
64
},setDisabled:function(_c){
65
if(_c){
66
if(this.disabled){
67
return;
68
}
69
if(this.animate){
70
this.nodeList.fadeOut().play();
71
}else{
72
this.nodeList.style("visibility","hidden");
73
}
74
this.disabled=true;
75
}else{
76
if(!this.disabled){
77
return;
78
}
79
if(this.animate){
80
this.nodeList.fadeIn().play();
81
}else{
82
this.nodeList.style("visibility","visible");
83
}
84
this.disabled=false;
85
}
86
},resize:function(_d){
87
var x;
88
var y;
89
if(_d){
90
x=_d.x;
91
y=_d.y;
92
}else{
93
var co=dojo._getBorderBox(this.node);
94
x=co.w;
95
y=co.h;
96
}
97
var _e=y-(this.shadowOffset+this.shadowThickness);
98
if(_e<0){
99
_e=0;
100
}
101
if(y<1){
102
y=1;
103
}
104
if(x<1){
105
x=1;
106
}
107
with(this.pieces){
108
l.style.height=_e+"px";
109
r.style.height=_e+"px";
110
b.style.width=x+"px";
111
bl.style.top=y+"px";
112
b.style.top=y+"px";
113
br.style.top=y+"px";
114
tr.style.left=x+"px";
115
r.style.left=x+"px";
116
br.style.left=x+"px";
117
}
118
}});
119
}