Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1318 Rev 1422
1
/*
1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
3
	All Rights Reserved.
4
 
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
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:
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
9
*/
-
 
10
 
-
 
11
 
10
 
12
 
11
dojo.provide("dojo.widget.Rounded");
13
dojo.provide("dojo.widget.Rounded");
12
dojo.widget.tags.addParseTreeHandler("dojo:rounded");
14
dojo.widget.tags.addParseTreeHandler("dojo:rounded");
13
dojo.require("dojo.widget.*");
15
dojo.require("dojo.widget.*");
14
dojo.require("dojo.widget.ContentPane");
16
dojo.require("dojo.widget.ContentPane");
15
dojo.require("dojo.html.style");
17
dojo.require("dojo.html.style");
16
dojo.require("dojo.html.display");
18
dojo.require("dojo.html.display");
17
dojo.require("dojo.gfx.color");
19
dojo.require("dojo.gfx.color");
18
dojo.deprecated("dojo.widget.Rounded will be removed in version 0.5; you can now apply rounded corners to any block element using dojo.lfx.rounded.", "0.5");
20
dojo.deprecated("dojo.widget.Rounded will be removed in version 0.5; you can now apply rounded corners to any block element using dojo.lfx.rounded.", "0.5");
19
dojo.widget.defineWidget("dojo.widget.Rounded", dojo.widget.ContentPane, {isSafari:dojo.render.html.safari, boxMargin:"50px", radius:14, domNode:"", corners:"TR,TL,BR,BL", antiAlias:true, fillInTemplate:function (args, frag) {
21
dojo.widget.defineWidget("dojo.widget.Rounded", dojo.widget.ContentPane, {isSafari:dojo.render.html.safari, boxMargin:"50px", radius:14, domNode:"", corners:"TR,TL,BR,BL", antiAlias:true, fillInTemplate:function (args, frag) {
20
	dojo.widget.Rounded.superclass.fillInTemplate.call(this, args, frag);
22
	dojo.widget.Rounded.superclass.fillInTemplate.call(this, args, frag);
21
	dojo.html.insertCssFile(this.templateCssPath);
23
	dojo.html.insertCssFile(this.templateCssPath);
22
	if (this.domNode.style.height <= 0) {
24
	if (this.domNode.style.height <= 0) {
23
		var minHeight = (this.radius * 1) + this.domNode.clientHeight;
25
		var minHeight = (this.radius * 1) + this.domNode.clientHeight;
24
		this.domNode.style.height = minHeight + "px";
26
		this.domNode.style.height = minHeight + "px";
25
	}
27
	}
26
	if (this.domNode.style.width <= 0) {
28
	if (this.domNode.style.width <= 0) {
27
		var minWidth = (this.radius * 1) + this.domNode.clientWidth;
29
		var minWidth = (this.radius * 1) + this.domNode.clientWidth;
28
		this.domNode.style.width = minWidth + "px";
30
		this.domNode.style.width = minWidth + "px";
29
	}
31
	}
30
	var cornersAvailable = ["TR", "TL", "BR", "BL"];
32
	var cornersAvailable = ["TR", "TL", "BR", "BL"];
31
	var cornersPassed = this.corners.split(",");
33
	var cornersPassed = this.corners.split(",");
32
	this.settings = {antiAlias:this.antiAlias};
34
	this.settings = {antiAlias:this.antiAlias};
33
	var setCorner = function (currentCorner) {
35
	var setCorner = function (currentCorner) {
34
		var val = currentCorner.toLowerCase();
36
		var val = currentCorner.toLowerCase();
35
		if (dojo.lang.inArray(cornersPassed, currentCorner)) {
37
		if (dojo.lang.inArray(cornersPassed, currentCorner)) {
36
			this.settings[val] = {radius:this.radius, enabled:true};
38
			this.settings[val] = {radius:this.radius, enabled:true};
37
		} else {
39
		} else {
38
			this.settings[val] = {radius:0};
40
			this.settings[val] = {radius:0};
39
		}
41
		}
40
	};
42
	};
41
	dojo.lang.forEach(cornersAvailable, setCorner, this);
43
	dojo.lang.forEach(cornersAvailable, setCorner, this);
42
	this.domNode.style.margin = this.boxMargin;
44
	this.domNode.style.margin = this.boxMargin;
43
	this.curvyCorners(this.settings);
45
	this.curvyCorners(this.settings);
44
	this.applyCorners();
46
	this.applyCorners();
45
}, curvyCorners:function (settings) {
47
}, curvyCorners:function (settings) {
46
	this.box = this.domNode;
48
	this.box = this.domNode;
47
	this.topContainer = null;
49
	this.topContainer = null;
48
	this.bottomContainer = null;
50
	this.bottomContainer = null;
49
	this.masterCorners = [];
51
	this.masterCorners = [];
50
	var boxHeight = dojo.html.getStyle(this.box, "height");
52
	var boxHeight = dojo.html.getStyle(this.box, "height");
51
	if (boxHeight == "") {
53
	if (boxHeight == "") {
52
		boxHeight = "0px";
54
		boxHeight = "0px";
53
	}
55
	}
54
	var boxWidth = dojo.html.getStyle(this.box, "width");
56
	var boxWidth = dojo.html.getStyle(this.box, "width");
55
	var borderWidth = dojo.html.getStyle(this.box, "borderTopWidth");
57
	var borderWidth = dojo.html.getStyle(this.box, "borderTopWidth");
56
	if (borderWidth == "") {
58
	if (borderWidth == "") {
57
		borderWidth = "0px";
59
		borderWidth = "0px";
58
	}
60
	}
59
	var borderColour = dojo.html.getStyle(this.box, "borderTopColor");
61
	var borderColour = dojo.html.getStyle(this.box, "borderTopColor");
60
	if (borderWidth > 0) {
62
	if (borderWidth > 0) {
61
		this.antiAlias = true;
63
		this.antiAlias = true;
62
	}
64
	}
63
	var boxColour = dojo.html.getStyle(this.box, "backgroundColor");
65
	var boxColour = dojo.html.getStyle(this.box, "backgroundColor");
64
	var backgroundImage = dojo.html.getStyle(this.box, "backgroundImage");
66
	var backgroundImage = dojo.html.getStyle(this.box, "backgroundImage");
65
	var boxPosition = dojo.html.getStyle(this.box, "position");
67
	var boxPosition = dojo.html.getStyle(this.box, "position");
66
	this.boxHeight = parseInt(((boxHeight != "" && boxHeight != "auto" && boxHeight.indexOf("%") == -1) ? boxHeight.substring(0, boxHeight.indexOf("px")) : this.box.scrollHeight));
68
	this.boxHeight = parseInt(((boxHeight != "" && boxHeight != "auto" && boxHeight.indexOf("%") == -1) ? boxHeight.substring(0, boxHeight.indexOf("px")) : this.box.scrollHeight));
67
	this.boxWidth = parseInt(((boxWidth != "" && boxWidth != "auto" && boxWidth.indexOf("%") == -1) ? boxWidth.substring(0, boxWidth.indexOf("px")) : this.box.scrollWidth));
69
	this.boxWidth = parseInt(((boxWidth != "" && boxWidth != "auto" && boxWidth.indexOf("%") == -1) ? boxWidth.substring(0, boxWidth.indexOf("px")) : this.box.scrollWidth));
68
	this.borderWidth = parseInt(((borderWidth != "" && borderWidth.indexOf("px") !== -1) ? borderWidth.slice(0, borderWidth.indexOf("px")) : 0));
70
	this.borderWidth = parseInt(((borderWidth != "" && borderWidth.indexOf("px") !== -1) ? borderWidth.slice(0, borderWidth.indexOf("px")) : 0));
69
	var test = new dojo.gfx.color.Color(boxColour);
71
	var test = new dojo.gfx.color.Color(boxColour);
70
	this.boxColour = ((boxColour != "" && boxColour != "transparent") ? ((boxColour.substr(0, 3) == "rgb") ? this.rgb2Hex(boxColour) : boxColour) : "#ffffff");
72
	this.boxColour = ((boxColour != "" && boxColour != "transparent") ? ((boxColour.substr(0, 3) == "rgb") ? this.rgb2Hex(boxColour) : boxColour) : "#ffffff");
71
	this.borderColour = ((borderColour != "" && borderColour != "transparent" && this.borderWidth > 0) ? ((borderColour.substr(0, 3) == "rgb") ? this.rgb2Hex(borderColour) : borderColour) : this.boxColour);
73
	this.borderColour = ((borderColour != "" && borderColour != "transparent" && this.borderWidth > 0) ? ((borderColour.substr(0, 3) == "rgb") ? this.rgb2Hex(borderColour) : borderColour) : this.boxColour);
72
	this.borderString = this.borderWidth + "px" + " solid " + this.borderColour;
74
	this.borderString = this.borderWidth + "px" + " solid " + this.borderColour;
73
	this.backgroundImage = ((backgroundImage != "none") ? backgroundImage : "");
75
	this.backgroundImage = ((backgroundImage != "none") ? backgroundImage : "");
74
	if (boxPosition != "absolute") {
76
	if (boxPosition != "absolute") {
75
		this.box.style.position = "relative";
77
		this.box.style.position = "relative";
76
	}
78
	}
77
	this.applyCorners = function () {
79
	this.applyCorners = function () {
78
		for (var t = 0; t < 2; t++) {
80
		for (var t = 0; t < 2; t++) {
79
			switch (t) {
81
			switch (t) {
80
			  case 0:
82
			  case 0:
81
				if (this.settings.tl.enabled || this.settings.tr.enabled) {
83
				if (this.settings.tl.enabled || this.settings.tr.enabled) {
82
					var newMainContainer = document.createElement("DIV");
84
					var newMainContainer = document.createElement("DIV");
83
					with (newMainContainer.style) {
85
					with (newMainContainer.style) {
84
						width = "100%";
86
						width = "100%";
85
						fontSize = "1px";
87
						fontSize = "1px";
86
						overflow = "hidden";
88
						overflow = "hidden";
87
						position = "absolute";
89
						position = "absolute";
88
						paddingLeft = this.borderWidth + "px";
90
						paddingLeft = this.borderWidth + "px";
89
						paddingRight = this.borderWidth + "px";
91
						paddingRight = this.borderWidth + "px";
90
						var topMaxRadius = Math.max(this.settings.tl ? this.settings.tl.radius : 0, this.settings.tr ? this.settings.tr.radius : 0);
92
						var topMaxRadius = Math.max(this.settings.tl ? this.settings.tl.radius : 0, this.settings.tr ? this.settings.tr.radius : 0);
91
						height = topMaxRadius + "px";
93
						height = topMaxRadius + "px";
92
						top = 0 - topMaxRadius + "px";
94
						top = 0 - topMaxRadius + "px";
93
						left = 0 - this.borderWidth + "px";
95
						left = 0 - this.borderWidth + "px";
94
					}
96
					}
95
					this.topContainer = this.box.appendChild(newMainContainer);
97
					this.topContainer = this.box.appendChild(newMainContainer);
96
				}
98
				}
97
				break;
99
				break;
98
			  case 1:
100
			  case 1:
99
				if (this.settings.bl.enabled || this.settings.br.enabled) {
101
				if (this.settings.bl.enabled || this.settings.br.enabled) {
100
					var newMainContainer = document.createElement("DIV");
102
					var newMainContainer = document.createElement("DIV");
101
					with (newMainContainer.style) {
103
					with (newMainContainer.style) {
102
						width = "100%";
104
						width = "100%";
103
						fontSize = "1px";
105
						fontSize = "1px";
104
						overflow = "hidden";
106
						overflow = "hidden";
105
						position = "absolute";
107
						position = "absolute";
106
						paddingLeft = this.borderWidth + "px";
108
						paddingLeft = this.borderWidth + "px";
107
						paddingRight = this.borderWidth + "px";
109
						paddingRight = this.borderWidth + "px";
108
						var botMaxRadius = Math.max(this.settings.bl ? this.settings.bl.radius : 0, this.settings.br ? this.settings.br.radius : 0);
110
						var botMaxRadius = Math.max(this.settings.bl ? this.settings.bl.radius : 0, this.settings.br ? this.settings.br.radius : 0);
109
						height = botMaxRadius + "px";
111
						height = botMaxRadius + "px";
110
						bottom = 0 - botMaxRadius + "px";
112
						bottom = 0 - botMaxRadius + "px";
111
						left = 0 - this.borderWidth + "px";
113
						left = 0 - this.borderWidth + "px";
112
					}
114
					}
113
					this.bottomContainer = this.box.appendChild(newMainContainer);
115
					this.bottomContainer = this.box.appendChild(newMainContainer);
114
				}
116
				}
115
				break;
117
				break;
116
			}
118
			}
117
		}
119
		}
118
		if (this.topContainer) {
120
		if (this.topContainer) {
119
			this.box.style.borderTopWidth = "0px";
121
			this.box.style.borderTopWidth = "0px";
120
		}
122
		}
121
		if (this.bottomContainer) {
123
		if (this.bottomContainer) {
122
			this.box.style.borderBottomWidth = "0px";
124
			this.box.style.borderBottomWidth = "0px";
123
		}
125
		}
124
		var corners = ["tr", "tl", "br", "bl"];
126
		var corners = ["tr", "tl", "br", "bl"];
125
		for (var i in corners) {
127
		for (var i in corners) {
126
			var cc = corners[i];
128
			var cc = corners[i];
127
			if (!this.settings[cc]) {
129
			if (!this.settings[cc]) {
128
				if (((cc == "tr" || cc == "tl") && this.topContainer != null) || ((cc == "br" || cc == "bl") && this.bottomContainer != null)) {
130
				if (((cc == "tr" || cc == "tl") && this.topContainer != null) || ((cc == "br" || cc == "bl") && this.bottomContainer != null)) {
129
					var newCorner = document.createElement("DIV");
131
					var newCorner = document.createElement("DIV");
130
					newCorner.style.position = "relative";
132
					newCorner.style.position = "relative";
131
					newCorner.style.fontSize = "1px";
133
					newCorner.style.fontSize = "1px";
132
					newCorner.style.overflow = "hidden";
134
					newCorner.style.overflow = "hidden";
133
					if (this.backgroundImage == "") {
135
					if (this.backgroundImage == "") {
134
						newCorner.style.backgroundColor = this.boxColour;
136
						newCorner.style.backgroundColor = this.boxColour;
135
					} else {
137
					} else {
136
						newCorner.style.backgroundImage = this.backgroundImage;
138
						newCorner.style.backgroundImage = this.backgroundImage;
137
					}
139
					}
138
					switch (cc) {
140
					switch (cc) {
139
					  case "tl":
141
					  case "tl":
140
						with (newCorner.style) {
142
						with (newCorner.style) {
141
							height = topMaxRadius - this.borderWidth + "px";
143
							height = topMaxRadius - this.borderWidth + "px";
142
							marginRight = this.settings.tr.radius - (this.borderWidth * 2) + "px";
144
							marginRight = this.settings.tr.radius - (this.borderWidth * 2) + "px";
143
							borderLeft = this.borderString;
145
							borderLeft = this.borderString;
144
							borderTop = this.borderString;
146
							borderTop = this.borderString;
145
							left = -this.borderWidth + "px";
147
							left = -this.borderWidth + "px";
146
						}
148
						}
147
						break;
149
						break;
148
					  case "tr":
150
					  case "tr":
149
						with (newCorner.style) {
151
						with (newCorner.style) {
150
							height = topMaxRadius - this.borderWidth + "px";
152
							height = topMaxRadius - this.borderWidth + "px";
151
							marginLeft = this.settings.tl.radius - (this.borderWidth * 2) + "px";
153
							marginLeft = this.settings.tl.radius - (this.borderWidth * 2) + "px";
152
							borderRight = this.borderString;
154
							borderRight = this.borderString;
153
							borderTop = this.borderString;
155
							borderTop = this.borderString;
154
							backgroundPosition = "-" + this.boxWidth + "px 0px";
156
							backgroundPosition = "-" + this.boxWidth + "px 0px";
155
							left = this.borderWidth + "px";
157
							left = this.borderWidth + "px";
156
						}
158
						}
157
						break;
159
						break;
158
					  case "bl":
160
					  case "bl":
159
						with (newCorner.style) {
161
						with (newCorner.style) {
160
							height = botMaxRadius - this.borderWidth + "px";
162
							height = botMaxRadius - this.borderWidth + "px";
161
							marginRight = this.settings.br.radius - (this.borderWidth * 2) + "px";
163
							marginRight = this.settings.br.radius - (this.borderWidth * 2) + "px";
162
							borderLeft = this.borderString;
164
							borderLeft = this.borderString;
163
							borderBottom = this.borderString;
165
							borderBottom = this.borderString;
164
							left = -this.borderWidth + "px";
166
							left = -this.borderWidth + "px";
165
						}
167
						}
166
						break;
168
						break;
167
					  case "br":
169
					  case "br":
168
						with (newCorner.style) {
170
						with (newCorner.style) {
169
							height = botMaxRadius - this.borderWidth + "px";
171
							height = botMaxRadius - this.borderWidth + "px";
170
							marginLeft = this.settings.bl.radius - (this.borderWidth * 2) + "px";
172
							marginLeft = this.settings.bl.radius - (this.borderWidth * 2) + "px";
171
							borderRight = this.borderString;
173
							borderRight = this.borderString;
172
							borderBottom = this.borderString;
174
							borderBottom = this.borderString;
173
							left = this.borderWidth + "px";
175
							left = this.borderWidth + "px";
174
						}
176
						}
175
						break;
177
						break;
176
					}
178
					}
177
				}
179
				}
178
			} else {
180
			} else {
179
				if (this.masterCorners[this.settings[cc].radius]) {
181
				if (this.masterCorners[this.settings[cc].radius]) {
180
					var newCorner = this.masterCorners[this.settings[cc].radius].cloneNode(true);
182
					var newCorner = this.masterCorners[this.settings[cc].radius].cloneNode(true);
181
				} else {
183
				} else {
182
					var newCorner = document.createElement("DIV");
184
					var newCorner = document.createElement("DIV");
183
					with (newCorner.style) {
185
					with (newCorner.style) {
184
						height = this.settings[cc].radius + "px";
186
						height = this.settings[cc].radius + "px";
185
						width = this.settings[cc].radius + "px";
187
						width = this.settings[cc].radius + "px";
186
						position = "absolute";
188
						position = "absolute";
187
						fontSize = "1px";
189
						fontSize = "1px";
188
						overflow = "hidden";
190
						overflow = "hidden";
189
					}
191
					}
190
					var borderRadius = parseInt(this.settings[cc].radius - this.borderWidth);
192
					var borderRadius = parseInt(this.settings[cc].radius - this.borderWidth);
191
					for (var intx = 0, j = this.settings[cc].radius; intx < j; intx++) {
193
					for (var intx = 0, j = this.settings[cc].radius; intx < j; intx++) {
192
						if ((intx + 1) >= borderRadius) {
194
						if ((intx + 1) >= borderRadius) {
193
							var y1 = -1;
195
							var y1 = -1;
194
						} else {
196
						} else {
195
							var y1 = (Math.floor(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow((intx + 1), 2))) - 1);
197
							var y1 = (Math.floor(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow((intx + 1), 2))) - 1);
196
						}
198
						}
197
						if (borderRadius != j) {
199
						if (borderRadius != j) {
198
							if ((intx) >= borderRadius) {
200
							if ((intx) >= borderRadius) {
199
								var y2 = -1;
201
								var y2 = -1;
200
							} else {
202
							} else {
201
								var y2 = Math.ceil(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow(intx, 2)));
203
								var y2 = Math.ceil(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow(intx, 2)));
202
							}
204
							}
203
							if ((intx + 1) >= j) {
205
							if ((intx + 1) >= j) {
204
								var y3 = -1;
206
								var y3 = -1;
205
							} else {
207
							} else {
206
								var y3 = (Math.floor(Math.sqrt(Math.pow(j, 2) - Math.pow((intx + 1), 2))) - 1);
208
								var y3 = (Math.floor(Math.sqrt(Math.pow(j, 2) - Math.pow((intx + 1), 2))) - 1);
207
							}
209
							}
208
						}
210
						}
209
						if ((intx) >= j) {
211
						if ((intx) >= j) {
210
							var y4 = -1;
212
							var y4 = -1;
211
						} else {
213
						} else {
212
							var y4 = Math.ceil(Math.sqrt(Math.pow(j, 2) - Math.pow(intx, 2)));
214
							var y4 = Math.ceil(Math.sqrt(Math.pow(j, 2) - Math.pow(intx, 2)));
213
						}
215
						}
214
						if (y1 > -1) {
216
						if (y1 > -1) {
215
							this.drawPixel(intx, 0, this.boxColour, 100, (y1 + 1), newCorner, -1, this.settings[cc].radius);
217
							this.drawPixel(intx, 0, this.boxColour, 100, (y1 + 1), newCorner, -1, this.settings[cc].radius);
216
						}
218
						}
217
						if (borderRadius != j) {
219
						if (borderRadius != j) {
218
							if (this.antiAlias) {
220
							if (this.antiAlias) {
219
								for (var inty = (y1 + 1); inty < y2; inty++) {
221
								for (var inty = (y1 + 1); inty < y2; inty++) {
220
									if (this.backgroundImage != "") {
222
									if (this.backgroundImage != "") {
221
										var borderFract = (this.pixelFraction(intx, inty, borderRadius) * 100);
223
										var borderFract = (this.pixelFraction(intx, inty, borderRadius) * 100);
222
										if (borderFract < 30) {
224
										if (borderFract < 30) {
223
											this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, 0, this.settings[cc].radius);
225
											this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, 0, this.settings[cc].radius);
224
										} else {
226
										} else {
225
											this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, -1, this.settings[cc].radius);
227
											this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, -1, this.settings[cc].radius);
226
										}
228
										}
227
									} else {
229
									} else {
228
										var pixelcolour = dojo.gfx.color.blend(this.boxColour, this.borderColour, this.pixelFraction(intx, inty, borderRadius));
230
										var pixelcolour = dojo.gfx.color.blend(this.boxColour, this.borderColour, this.pixelFraction(intx, inty, borderRadius));
229
										this.drawPixel(intx, inty, pixelcolour, 100, 1, newCorner, 0, this.settings[cc].radius);
231
										this.drawPixel(intx, inty, pixelcolour, 100, 1, newCorner, 0, this.settings[cc].radius);
230
									}
232
									}
231
								}
233
								}
232
							}
234
							}
233
							if (y3 >= y2) {
235
							if (y3 >= y2) {
234
								if (y1 == -1) {
236
								if (y1 == -1) {
235
									y1 = 0;
237
									y1 = 0;
236
								}
238
								}
237
								this.drawPixel(intx, y2, this.borderColour, 100, (y3 - y2 + 1), newCorner, 0, this.settings[cc].radius);
239
								this.drawPixel(intx, y2, this.borderColour, 100, (y3 - y2 + 1), newCorner, 0, this.settings[cc].radius);
238
							}
240
							}
239
							var outsideColour = this.borderColour;
241
							var outsideColour = this.borderColour;
240
						} else {
242
						} else {
241
							var outsideColour = this.boxColour;
243
							var outsideColour = this.boxColour;
242
							var y3 = y1;
244
							var y3 = y1;
243
						}
245
						}
244
						if (this.antiAlias) {
246
						if (this.antiAlias) {
245
							for (var inty = (y3 + 1); inty < y4; inty++) {
247
							for (var inty = (y3 + 1); inty < y4; inty++) {
246
								this.drawPixel(intx, inty, outsideColour, (this.pixelFraction(intx, inty, j) * 100), 1, newCorner, ((this.borderWidth > 0) ? 0 : -1), this.settings[cc].radius);
248
								this.drawPixel(intx, inty, outsideColour, (this.pixelFraction(intx, inty, j) * 100), 1, newCorner, ((this.borderWidth > 0) ? 0 : -1), this.settings[cc].radius);
247
							}
249
							}
248
						}
250
						}
249
					}
251
					}
250
					this.masterCorners[this.settings[cc].radius] = newCorner.cloneNode(true);
252
					this.masterCorners[this.settings[cc].radius] = newCorner.cloneNode(true);
251
				}
253
				}
252
				if (cc != "br") {
254
				if (cc != "br") {
253
					for (var t = 0, k = newCorner.childNodes.length; t < k; t++) {
255
					for (var t = 0, k = newCorner.childNodes.length; t < k; t++) {
254
						var pixelBar = newCorner.childNodes[t];
256
						var pixelBar = newCorner.childNodes[t];
255
						var pixelBarTop = parseInt(pixelBar.style.top.substring(0, pixelBar.style.top.indexOf("px")));
257
						var pixelBarTop = parseInt(pixelBar.style.top.substring(0, pixelBar.style.top.indexOf("px")));
256
						var pixelBarLeft = parseInt(pixelBar.style.left.substring(0, pixelBar.style.left.indexOf("px")));
258
						var pixelBarLeft = parseInt(pixelBar.style.left.substring(0, pixelBar.style.left.indexOf("px")));
257
						var pixelBarHeight = parseInt(pixelBar.style.height.substring(0, pixelBar.style.height.indexOf("px")));
259
						var pixelBarHeight = parseInt(pixelBar.style.height.substring(0, pixelBar.style.height.indexOf("px")));
258
						if (cc == "tl" || cc == "bl") {
260
						if (cc == "tl" || cc == "bl") {
259
							pixelBar.style.left = this.settings[cc].radius - pixelBarLeft - 1 + "px";
261
							pixelBar.style.left = this.settings[cc].radius - pixelBarLeft - 1 + "px";
260
						}
262
						}
261
						if (cc == "tr" || cc == "tl") {
263
						if (cc == "tr" || cc == "tl") {
262
							pixelBar.style.top = this.settings[cc].radius - pixelBarHeight - pixelBarTop + "px";
264
							pixelBar.style.top = this.settings[cc].radius - pixelBarHeight - pixelBarTop + "px";
263
						}
265
						}
264
						var value;
266
						var value;
265
						switch (cc) {
267
						switch (cc) {
266
						  case "tr":
268
						  case "tr":
267
							value = (-1 * (Math.abs((this.boxWidth - this.settings[cc].radius + this.borderWidth) + pixelBarLeft) - (Math.abs(this.settings[cc].radius - pixelBarHeight - pixelBarTop - this.borderWidth))));
269
							value = (-1 * (Math.abs((this.boxWidth - this.settings[cc].radius + this.borderWidth) + pixelBarLeft) - (Math.abs(this.settings[cc].radius - pixelBarHeight - pixelBarTop - this.borderWidth))));
268
							pixelBar.style.backgroundPosition = value + "px";
270
							pixelBar.style.backgroundPosition = value + "px";
269
							break;
271
							break;
270
						  case "tl":
272
						  case "tl":
271
							value = (-1 * (Math.abs((this.settings[cc].radius - pixelBarLeft - 1) - this.borderWidth) - (Math.abs(this.settings[cc].radius - pixelBarHeight - pixelBarTop - this.borderWidth))));
273
							value = (-1 * (Math.abs((this.settings[cc].radius - pixelBarLeft - 1) - this.borderWidth) - (Math.abs(this.settings[cc].radius - pixelBarHeight - pixelBarTop - this.borderWidth))));
272
							pixelBar.style.backgroundPosition = value + "px";
274
							pixelBar.style.backgroundPosition = value + "px";
273
							break;
275
							break;
274
						  case "bl":
276
						  case "bl":
275
							value = (-1 * (Math.abs((this.settings[cc].radius - pixelBarLeft - 1) - this.borderWidth) - (Math.abs((this.boxHeight + this.settings[cc].radius + pixelBarTop) - this.borderWidth))));
277
							value = (-1 * (Math.abs((this.settings[cc].radius - pixelBarLeft - 1) - this.borderWidth) - (Math.abs((this.boxHeight + this.settings[cc].radius + pixelBarTop) - this.borderWidth))));
276
							pixelBar.style.backgroundPosition = value + "px";
278
							pixelBar.style.backgroundPosition = value + "px";
277
							break;
279
							break;
278
						}
280
						}
279
					}
281
					}
280
				}
282
				}
281
			}
283
			}
282
			if (newCorner) {
284
			if (newCorner) {
283
				switch (cc) {
285
				switch (cc) {
284
				  case "tl":
286
				  case "tl":
285
					if (newCorner.style.position == "absolute") {
287
					if (newCorner.style.position == "absolute") {
286
						newCorner.style.top = "0px";
288
						newCorner.style.top = "0px";
287
					}
289
					}
288
					if (newCorner.style.position == "absolute") {
290
					if (newCorner.style.position == "absolute") {
289
						newCorner.style.left = "0px";
291
						newCorner.style.left = "0px";
290
					}
292
					}
291
					if (this.topContainer) {
293
					if (this.topContainer) {
292
						this.topContainer.appendChild(newCorner);
294
						this.topContainer.appendChild(newCorner);
293
					}
295
					}
294
					break;
296
					break;
295
				  case "tr":
297
				  case "tr":
296
					if (newCorner.style.position == "absolute") {
298
					if (newCorner.style.position == "absolute") {
297
						newCorner.style.top = "0px";
299
						newCorner.style.top = "0px";
298
					}
300
					}
299
					if (newCorner.style.position == "absolute") {
301
					if (newCorner.style.position == "absolute") {
300
						newCorner.style.right = "0px";
302
						newCorner.style.right = "0px";
301
					}
303
					}
302
					if (this.topContainer) {
304
					if (this.topContainer) {
303
						this.topContainer.appendChild(newCorner);
305
						this.topContainer.appendChild(newCorner);
304
					}
306
					}
305
					break;
307
					break;
306
				  case "bl":
308
				  case "bl":
307
					if (newCorner.style.position == "absolute") {
309
					if (newCorner.style.position == "absolute") {
308
						newCorner.style.bottom = "0px";
310
						newCorner.style.bottom = "0px";
309
					}
311
					}
310
					if (newCorner.style.position == "absolute") {
312
					if (newCorner.style.position == "absolute") {
311
						newCorner.style.left = "0px";
313
						newCorner.style.left = "0px";
312
					}
314
					}
313
					if (this.bottomContainer) {
315
					if (this.bottomContainer) {
314
						this.bottomContainer.appendChild(newCorner);
316
						this.bottomContainer.appendChild(newCorner);
315
					}
317
					}
316
					break;
318
					break;
317
				  case "br":
319
				  case "br":
318
					if (newCorner.style.position == "absolute") {
320
					if (newCorner.style.position == "absolute") {
319
						newCorner.style.bottom = "0px";
321
						newCorner.style.bottom = "0px";
320
					}
322
					}
321
					if (newCorner.style.position == "absolute") {
323
					if (newCorner.style.position == "absolute") {
322
						newCorner.style.right = "0px";
324
						newCorner.style.right = "0px";
323
					}
325
					}
324
					if (this.bottomContainer) {
326
					if (this.bottomContainer) {
325
						this.bottomContainer.appendChild(newCorner);
327
						this.bottomContainer.appendChild(newCorner);
326
					}
328
					}
327
					break;
329
					break;
328
				}
330
				}
329
			}
331
			}
330
		}
332
		}
331
		var radiusDiff = [];
333
		var radiusDiff = [];
332
		radiusDiff["t"] = this.settings.tl.enabled && this.settings.tr.enabled ? Math.abs(this.settings.tl.radius - this.settings.tr.radius) : 0;
334
		radiusDiff["t"] = this.settings.tl.enabled && this.settings.tr.enabled ? Math.abs(this.settings.tl.radius - this.settings.tr.radius) : 0;
333
		radiusDiff["b"] = this.settings.bl.enabled && this.settings.br.enabled ? Math.abs(this.settings.bl.radius - this.settings.br.radius) : 0;
335
		radiusDiff["b"] = this.settings.bl.enabled && this.settings.br.enabled ? Math.abs(this.settings.bl.radius - this.settings.br.radius) : 0;
334
		for (var z in radiusDiff) {
336
		for (var z in radiusDiff) {
335
			if (radiusDiff[z]) {
337
			if (radiusDiff[z]) {
336
				var smallerCornerType = ((this.settings[z + "l"].radius < this.settings[z + "r"].radius) ? z + "l" : z + "r");
338
				var smallerCornerType = ((this.settings[z + "l"].radius < this.settings[z + "r"].radius) ? z + "l" : z + "r");
337
				var newFiller = document.createElement("DIV");
339
				var newFiller = document.createElement("DIV");
338
				with (newFiller.style) {
340
				with (newFiller.style) {
339
					height = radiusDiff[z] + "px";
341
					height = radiusDiff[z] + "px";
340
					width = this.settings[smallerCornerType].radius + "px";
342
					width = this.settings[smallerCornerType].radius + "px";
341
					position = "absolute";
343
					position = "absolute";
342
					fontSize = "1px";
344
					fontSize = "1px";
343
					overflow = "hidden";
345
					overflow = "hidden";
344
					backgroundColor = this.boxColour;
346
					backgroundColor = this.boxColour;
345
				}
347
				}
346
				switch (smallerCornerType) {
348
				switch (smallerCornerType) {
347
				  case "tl":
349
				  case "tl":
348
					with (newFiller.style) {
350
					with (newFiller.style) {
349
						bottom = "0px";
351
						bottom = "0px";
350
						left = "0px";
352
						left = "0px";
351
						borderLeft = this.borderString;
353
						borderLeft = this.borderString;
352
					}
354
					}
353
					this.topContainer.appendChild(newFiller);
355
					this.topContainer.appendChild(newFiller);
354
					break;
356
					break;
355
				  case "tr":
357
				  case "tr":
356
					with (newFiller.style) {
358
					with (newFiller.style) {
357
						bottom = "0px";
359
						bottom = "0px";
358
						right = "0px";
360
						right = "0px";
359
						borderRight = this.borderString;
361
						borderRight = this.borderString;
360
					}
362
					}
361
					this.topContainer.appendChild(newFiller);
363
					this.topContainer.appendChild(newFiller);
362
					break;
364
					break;
363
				  case "bl":
365
				  case "bl":
364
					with (newFiller.style) {
366
					with (newFiller.style) {
365
						top = "0px";
367
						top = "0px";
366
						left = "0px";
368
						left = "0px";
367
						borderLeft = this.borderString;
369
						borderLeft = this.borderString;
368
					}
370
					}
369
					this.bottomContainer.appendChild(newFiller);
371
					this.bottomContainer.appendChild(newFiller);
370
					break;
372
					break;
371
				  case "br":
373
				  case "br":
372
					with (newFiller.style) {
374
					with (newFiller.style) {
373
						top = "0px";
375
						top = "0px";
374
						right = "0px";
376
						right = "0px";
375
						borderRight = this.borderString;
377
						borderRight = this.borderString;
376
					}
378
					}
377
					this.bottomContainer.appendChild(newFiller);
379
					this.bottomContainer.appendChild(newFiller);
378
					break;
380
					break;
379
				}
381
				}
380
			}
382
			}
381
			var newFillerBar = document.createElement("DIV");
383
			var newFillerBar = document.createElement("DIV");
382
			with (newFillerBar.style) {
384
			with (newFillerBar.style) {
383
				position = "relative";
385
				position = "relative";
384
				fontSize = "1px";
386
				fontSize = "1px";
385
				overflow = "hidden";
387
				overflow = "hidden";
386
				backgroundColor = this.boxColour;
388
				backgroundColor = this.boxColour;
387
			}
389
			}
388
			switch (z) {
390
			switch (z) {
389
			  case "t":
391
			  case "t":
390
				if (this.topContainer) {
392
				if (this.topContainer) {
391
					with (newFillerBar.style) {
393
					with (newFillerBar.style) {
392
						height = topMaxRadius - this.borderWidth + "px";
394
						height = topMaxRadius - this.borderWidth + "px";
393
						marginLeft = this.settings.tl.radius - this.borderWidth + "px";
395
						marginLeft = this.settings.tl.radius - this.borderWidth + "px";
394
						marginRight = this.settings.tr.radius - this.borderWidth + "px";
396
						marginRight = this.settings.tr.radius - this.borderWidth + "px";
395
						borderTop = this.borderString;
397
						borderTop = this.borderString;
396
					}
398
					}
397
					this.topContainer.appendChild(newFillerBar);
399
					this.topContainer.appendChild(newFillerBar);
398
				}
400
				}
399
				break;
401
				break;
400
			  case "b":
402
			  case "b":
401
				if (this.bottomContainer) {
403
				if (this.bottomContainer) {
402
					with (newFillerBar.style) {
404
					with (newFillerBar.style) {
403
						height = botMaxRadius - this.borderWidth + "px";
405
						height = botMaxRadius - this.borderWidth + "px";
404
						marginLeft = this.settings.bl.radius - this.borderWidth + "px";
406
						marginLeft = this.settings.bl.radius - this.borderWidth + "px";
405
						marginRight = this.settings.br.radius - this.borderWidth + "px";
407
						marginRight = this.settings.br.radius - this.borderWidth + "px";
406
						borderBottom = this.borderString;
408
						borderBottom = this.borderString;
407
					}
409
					}
408
					this.bottomContainer.appendChild(newFillerBar);
410
					this.bottomContainer.appendChild(newFillerBar);
409
				}
411
				}
410
				break;
412
				break;
411
			}
413
			}
412
		}
414
		}
413
	};
415
	};
414
	this.drawPixel = function (intx, inty, colour, transAmount, height, newCorner, image, cornerRadius) {
416
	this.drawPixel = function (intx, inty, colour, transAmount, height, newCorner, image, cornerRadius) {
415
		var pixel = document.createElement("DIV");
417
		var pixel = document.createElement("DIV");
416
		pixel.style.height = height + "px";
418
		pixel.style.height = height + "px";
417
		pixel.style.width = "1px";
419
		pixel.style.width = "1px";
418
		pixel.style.position = "absolute";
420
		pixel.style.position = "absolute";
419
		pixel.style.fontSize = "1px";
421
		pixel.style.fontSize = "1px";
420
		pixel.style.overflow = "hidden";
422
		pixel.style.overflow = "hidden";
421
		if (image == -1 && this.backgroundImage != "") {
423
		if (image == -1 && this.backgroundImage != "") {
422
			pixel.style.backgroundImage = this.backgroundImage;
424
			pixel.style.backgroundImage = this.backgroundImage;
423
			pixel.style.backgroundPosition = "-" + (this.boxWidth - (cornerRadius - intx) + this.borderWidth) + "px -" + ((this.boxHeight + cornerRadius + inty) - this.borderWidth) + "px";
425
			pixel.style.backgroundPosition = "-" + (this.boxWidth - (cornerRadius - intx) + this.borderWidth) + "px -" + ((this.boxHeight + cornerRadius + inty) - this.borderWidth) + "px";
424
		} else {
426
		} else {
425
			pixel.style.backgroundColor = colour;
427
			pixel.style.backgroundColor = colour;
426
		}
428
		}
427
		if (transAmount != 100) {
429
		if (transAmount != 100) {
428
			dojo.html.setOpacity(pixel, transAmount);
430
			dojo.html.setOpacity(pixel, transAmount);
429
		}
431
		}
430
		pixel.style.top = inty + "px";
432
		pixel.style.top = inty + "px";
431
		pixel.style.left = intx + "px";
433
		pixel.style.left = intx + "px";
432
		newCorner.appendChild(pixel);
434
		newCorner.appendChild(pixel);
433
	};
435
	};
434
}, pixelFraction:function (x, y, r) {
436
}, pixelFraction:function (x, y, r) {
435
	var pixelfraction = 0;
437
	var pixelfraction = 0;
436
	var xvalues = [];
438
	var xvalues = [];
437
	var yvalues = [];
439
	var yvalues = [];
438
	var point = 0;
440
	var point = 0;
439
	var whatsides = "";
441
	var whatsides = "";
440
	var intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(x, 2)));
442
	var intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(x, 2)));
441
	if ((intersect >= y) && (intersect < (y + 1))) {
443
	if ((intersect >= y) && (intersect < (y + 1))) {
442
		whatsides = "Left";
444
		whatsides = "Left";
443
		xvalues[point] = 0;
445
		xvalues[point] = 0;
444
		yvalues[point] = intersect - y;
446
		yvalues[point] = intersect - y;
445
		point = point + 1;
447
		point = point + 1;
446
	}
448
	}
447
	var intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(y + 1, 2)));
449
	var intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(y + 1, 2)));
448
	if ((intersect >= x) && (intersect < (x + 1))) {
450
	if ((intersect >= x) && (intersect < (x + 1))) {
449
		whatsides = whatsides + "Top";
451
		whatsides = whatsides + "Top";
450
		xvalues[point] = intersect - x;
452
		xvalues[point] = intersect - x;
451
		yvalues[point] = 1;
453
		yvalues[point] = 1;
452
		point = point + 1;
454
		point = point + 1;
453
	}
455
	}
454
	var intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(x + 1, 2)));
456
	var intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(x + 1, 2)));
455
	if ((intersect >= y) && (intersect < (y + 1))) {
457
	if ((intersect >= y) && (intersect < (y + 1))) {
456
		whatsides = whatsides + "Right";
458
		whatsides = whatsides + "Right";
457
		xvalues[point] = 1;
459
		xvalues[point] = 1;
458
		yvalues[point] = intersect - y;
460
		yvalues[point] = intersect - y;
459
		point = point + 1;
461
		point = point + 1;
460
	}
462
	}
461
	var intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(y, 2)));
463
	var intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(y, 2)));
462
	if ((intersect >= x) && (intersect < (x + 1))) {
464
	if ((intersect >= x) && (intersect < (x + 1))) {
463
		whatsides = whatsides + "Bottom";
465
		whatsides = whatsides + "Bottom";
464
		xvalues[point] = intersect - x;
466
		xvalues[point] = intersect - x;
465
		yvalues[point] = 0;
467
		yvalues[point] = 0;
466
	}
468
	}
467
	switch (whatsides) {
469
	switch (whatsides) {
468
	  case "LeftRight":
470
	  case "LeftRight":
469
		pixelfraction = Math.min(yvalues[0], yvalues[1]) + ((Math.max(yvalues[0], yvalues[1]) - Math.min(yvalues[0], yvalues[1])) / 2);
471
		pixelfraction = Math.min(yvalues[0], yvalues[1]) + ((Math.max(yvalues[0], yvalues[1]) - Math.min(yvalues[0], yvalues[1])) / 2);
470
		break;
472
		break;
471
	  case "TopRight":
473
	  case "TopRight":
472
		pixelfraction = 1 - (((1 - xvalues[0]) * (1 - yvalues[1])) / 2);
474
		pixelfraction = 1 - (((1 - xvalues[0]) * (1 - yvalues[1])) / 2);
473
		break;
475
		break;
474
	  case "TopBottom":
476
	  case "TopBottom":
475
		pixelfraction = Math.min(xvalues[0], xvalues[1]) + ((Math.max(xvalues[0], xvalues[1]) - Math.min(xvalues[0], xvalues[1])) / 2);
477
		pixelfraction = Math.min(xvalues[0], xvalues[1]) + ((Math.max(xvalues[0], xvalues[1]) - Math.min(xvalues[0], xvalues[1])) / 2);
476
		break;
478
		break;
477
	  case "LeftBottom":
479
	  case "LeftBottom":
478
		pixelfraction = (yvalues[0] * xvalues[1]) / 2;
480
		pixelfraction = (yvalues[0] * xvalues[1]) / 2;
479
		break;
481
		break;
480
	  default:
482
	  default:
481
		pixelfraction = 1;
483
		pixelfraction = 1;
482
	}
484
	}
483
	return pixelfraction;
485
	return pixelfraction;
484
}, rgb2Hex:function (rgbColour) {
486
}, rgb2Hex:function (rgbColour) {
485
	try {
487
	try {
486
		var rgbArray = this.rgb2Array(rgbColour);
488
		var rgbArray = this.rgb2Array(rgbColour);
487
		var red = parseInt(rgbArray[0]);
489
		var red = parseInt(rgbArray[0]);
488
		var green = parseInt(rgbArray[1]);
490
		var green = parseInt(rgbArray[1]);
489
		var blue = parseInt(rgbArray[2]);
491
		var blue = parseInt(rgbArray[2]);
490
		var hexColour = "#" + this.intToHex(red) + this.intToHex(green) + this.intToHex(blue);
492
		var hexColour = "#" + this.intToHex(red) + this.intToHex(green) + this.intToHex(blue);
491
	}
493
	}
492
	catch (e) {
494
	catch (e) {
493
		alert("There was an error converting the RGB value to Hexadecimal in function rgb2Hex");
495
		alert("There was an error converting the RGB value to Hexadecimal in function rgb2Hex");
494
	}
496
	}
495
	return hexColour;
497
	return hexColour;
496
}, intToHex:function (strNum) {
498
}, intToHex:function (strNum) {
497
	var base = strNum / 16;
499
	var base = strNum / 16;
498
	var rem = strNum % 16;
500
	var rem = strNum % 16;
499
	var base = base - (rem / 16);
501
	var base = base - (rem / 16);
500
	var baseS = this.makeHex(base);
502
	var baseS = this.makeHex(base);
501
	var remS = this.makeHex(rem);
503
	var remS = this.makeHex(rem);
502
	return baseS + "" + remS;
504
	return baseS + "" + remS;
503
}, makeHex:function (x) {
505
}, makeHex:function (x) {
504
	if ((x >= 0) && (x <= 9)) {
506
	if ((x >= 0) && (x <= 9)) {
505
		return x;
507
		return x;
506
	} else {
508
	} else {
507
		switch (x) {
509
		switch (x) {
508
		  case 10:
510
		  case 10:
509
			return "A";
511
			return "A";
510
		  case 11:
512
		  case 11:
511
			return "B";
513
			return "B";
512
		  case 12:
514
		  case 12:
513
			return "C";
515
			return "C";
514
		  case 13:
516
		  case 13:
515
			return "D";
517
			return "D";
516
		  case 14:
518
		  case 14:
517
			return "E";
519
			return "E";
518
		  case 15:
520
		  case 15:
519
			return "F";
521
			return "F";
520
		}
522
		}
521
	}
523
	}
522
}, rgb2Array:function (rgbColour) {
524
}, rgb2Array:function (rgbColour) {
523
	var rgbValues = rgbColour.substring(4, rgbColour.indexOf(")"));
525
	var rgbValues = rgbColour.substring(4, rgbColour.indexOf(")"));
524
	var rgbArray = rgbValues.split(", ");
526
	var rgbArray = rgbValues.split(", ");
525
	return rgbArray;
527
	return rgbArray;
526
}});
528
}});
527
 
529