summaryrefslogtreecommitdiff
path: root/docroot/classes/roundcorners.class.js
blob: c156d308cedbb02e36a714d58bfd669b05c1b81f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * Material Experience - Card Chip Class
 * 
 * EYEMG - Interactive Media Group
 * Created by Mike Crute (mcrute@eyemg.com)
 * Updated by Mike Crute (mcrute@eyemg.com) on 9/26/07
 * 
 * An HTML based approach to drawing rounded corners using element
 * "slices" to create the corners instead of images. This depends 
 * on a section in the stylesheet to work correctly.
 * 
 * Code adapted from: http://www.html.it/articoli/nifty/index.html
 */

var RoundedCorners = Class.create();
Object.extend(RoundedCorners.prototype, 
{
	// Direction table for rounded corners.
	directions: 
	{
		top :    'top', 
		bottom : 'bottom' 
	},
	
	/* 
	 * Initialize the object
	 */
	initialize: function(color) 
	{
		this.color = color;
	},
	
	/*
	 * Creates a rounded corner container.
	 */
	get: function(direction) 
	{
		var slicebox = document.createElement('b');
		slicebox.className = 'round';
		
		if (direction == this.directions.top) 
		{
			var myEnum = $A($R(1,10));
		} 
		else 
		{
			var myEnum = $A($R(1,10)).reverse();
		}
		
		myEnum.each(function(item) 
		{
			var corner                   = document.createElement('b');
			corner.className             = 'rcSlice_' + item;
			corner.style.backgroundColor = this.color;
			slicebox.appendChild(corner);
		}.bind(this));
		
		return slicebox;
	}
});