Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | 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
 
11
dojo.provide("dojo.lfx.shadow");
12
dojo.require("dojo.lang.common");
13
dojo.require("dojo.uri.Uri");
14
dojo.lfx.shadow = function (node) {
15
	this.shadowPng = dojo.uri.moduleUri("dojo.html", "images/shadow");
16
	this.shadowThickness = 8;
17
	this.shadowOffset = 15;
18
	this.init(node);
19
};
20
dojo.extend(dojo.lfx.shadow, {init:function (node) {
21
	this.node = node;
22
	this.pieces = {};
23
	var x1 = -1 * this.shadowThickness;
24
	var y0 = this.shadowOffset;
25
	var y1 = this.shadowOffset + this.shadowThickness;
26
	this._makePiece("tl", "top", y0, "left", x1);
27
	this._makePiece("l", "top", y1, "left", x1, "scale");
28
	this._makePiece("tr", "top", y0, "left", 0);
29
	this._makePiece("r", "top", y1, "left", 0, "scale");
30
	this._makePiece("bl", "top", 0, "left", x1);
31
	this._makePiece("b", "top", 0, "left", 0, "crop");
32
	this._makePiece("br", "top", 0, "left", 0);
33
}, _makePiece:function (name, vertAttach, vertCoord, horzAttach, horzCoord, sizing) {
34
	var img;
35
	var url = this.shadowPng + name.toUpperCase() + ".png";
36
	if (dojo.render.html.ie55 || dojo.render.html.ie60) {
37
		img = dojo.doc().createElement("div");
38
		img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "'" + (sizing ? ", sizingMethod='" + sizing + "'" : "") + ")";
39
	} else {
40
		img = dojo.doc().createElement("img");
41
		img.src = url;
42
	}
43
	img.style.position = "absolute";
44
	img.style[vertAttach] = vertCoord + "px";
45
	img.style[horzAttach] = horzCoord + "px";
46
	img.style.width = this.shadowThickness + "px";
47
	img.style.height = this.shadowThickness + "px";
48
	this.pieces[name] = img;
49
	this.node.appendChild(img);
50
}, size:function (width, height) {
51
	var sideHeight = height - (this.shadowOffset + this.shadowThickness + 1);
52
	if (sideHeight < 0) {
53
		sideHeight = 0;
54
	}
55
	if (height < 1) {
56
		height = 1;
57
	}
58
	if (width < 1) {
59
		width = 1;
60
	}
61
	with (this.pieces) {
62
		l.style.height = sideHeight + "px";
63
		r.style.height = sideHeight + "px";
64
		b.style.width = (width - 1) + "px";
65
		bl.style.top = (height - 1) + "px";
66
		b.style.top = (height - 1) + "px";
67
		br.style.top = (height - 1) + "px";
68
		tr.style.left = (width - 1) + "px";
69
		r.style.left = (width - 1) + "px";
70
		br.style.left = (width - 1) + "px";
71
	}
72
}});
73