Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.lfx.shadow");
14
dojo.require("dojo.lang.common");
15
dojo.require("dojo.uri.Uri");
16
dojo.lfx.shadow = function (node) {
17
	this.shadowPng = dojo.uri.moduleUri("dojo.html", "images/shadow");
18
	this.shadowThickness = 8;
19
	this.shadowOffset = 15;
20
	this.init(node);
21
};
22
dojo.extend(dojo.lfx.shadow, {init:function (node) {
23
	this.node = node;
24
	this.pieces = {};
25
	var x1 = -1 * this.shadowThickness;
26
	var y0 = this.shadowOffset;
27
	var y1 = this.shadowOffset + this.shadowThickness;
28
	this._makePiece("tl", "top", y0, "left", x1);
29
	this._makePiece("l", "top", y1, "left", x1, "scale");
30
	this._makePiece("tr", "top", y0, "left", 0);
31
	this._makePiece("r", "top", y1, "left", 0, "scale");
32
	this._makePiece("bl", "top", 0, "left", x1);
33
	this._makePiece("b", "top", 0, "left", 0, "crop");
34
	this._makePiece("br", "top", 0, "left", 0);
35
}, _makePiece:function (name, vertAttach, vertCoord, horzAttach, horzCoord, sizing) {
36
	var img;
37
	var url = this.shadowPng + name.toUpperCase() + ".png";
38
	if (dojo.render.html.ie55 || dojo.render.html.ie60) {
39
		img = dojo.doc().createElement("div");
40
		img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "'" + (sizing ? ", sizingMethod='" + sizing + "'" : "") + ")";
41
	} else {
42
		img = dojo.doc().createElement("img");
43
		img.src = url;
44
	}
45
	img.style.position = "absolute";
46
	img.style[vertAttach] = vertCoord + "px";
47
	img.style[horzAttach] = horzCoord + "px";
48
	img.style.width = this.shadowThickness + "px";
49
	img.style.height = this.shadowThickness + "px";
50
	this.pieces[name] = img;
51
	this.node.appendChild(img);
52
}, size:function (width, height) {
53
	var sideHeight = height - (this.shadowOffset + this.shadowThickness + 1);
54
	if (sideHeight < 0) {
55
		sideHeight = 0;
56
	}
57
	if (height < 1) {
58
		height = 1;
59
	}
60
	if (width < 1) {
61
		width = 1;
62
	}
63
	with (this.pieces) {
64
		l.style.height = sideHeight + "px";
65
		r.style.height = sideHeight + "px";
66
		b.style.width = (width - 1) + "px";
67
		bl.style.top = (height - 1) + "px";
68
		b.style.top = (height - 1) + "px";
69
		br.style.top = (height - 1) + "px";
70
		tr.style.left = (width - 1) + "px";
71
		r.style.left = (width - 1) + "px";
72
		br.style.left = (width - 1) + "px";
73
	}
74
}});
75