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.widget.ColorPalette");
12
dojo.require("dojo.widget.*");
13
dojo.require("dojo.html.layout");
14
dojo.require("dojo.html.display");
15
dojo.require("dojo.html.selection");
16
dojo.widget.defineWidget("dojo.widget.ColorPalette", dojo.widget.HtmlWidget, {palette:"7x10", _palettes:{"7x10":[["fff", "fcc", "fc9", "ff9", "ffc", "9f9", "9ff", "cff", "ccf", "fcf"], ["ccc", "f66", "f96", "ff6", "ff3", "6f9", "3ff", "6ff", "99f", "f9f"], ["c0c0c0", "f00", "f90", "fc6", "ff0", "3f3", "6cc", "3cf", "66c", "c6c"], ["999", "c00", "f60", "fc3", "fc0", "3c0", "0cc", "36f", "63f", "c3c"], ["666", "900", "c60", "c93", "990", "090", "399", "33f", "60c", "939"], ["333", "600", "930", "963", "660", "060", "366", "009", "339", "636"], ["000", "300", "630", "633", "330", "030", "033", "006", "309", "303"]], "3x4":[["ffffff", "00ff00", "008000", "0000ff"], ["c0c0c0", "ffff00", "ff00ff", "000080"], ["808080", "ff0000", "800080", "000000"]]}, buildRendering:function () {
17
	this.domNode = document.createElement("table");
18
	dojo.html.disableSelection(this.domNode);
19
	dojo.event.connect(this.domNode, "onmousedown", function (e) {
20
		e.preventDefault();
21
	});
22
	with (this.domNode) {
23
		cellPadding = "0";
24
		cellSpacing = "1";
25
		border = "1";
26
		style.backgroundColor = "white";
27
	}
28
	var colors = this._palettes[this.palette];
29
	for (var i = 0; i < colors.length; i++) {
30
		var tr = this.domNode.insertRow(-1);
31
		for (var j = 0; j < colors[i].length; j++) {
32
			if (colors[i][j].length == 3) {
33
				colors[i][j] = colors[i][j].replace(/(.)(.)(.)/, "$1$1$2$2$3$3");
34
			}
35
			var td = tr.insertCell(-1);
36
			with (td.style) {
37
				backgroundColor = "#" + colors[i][j];
38
				border = "1px solid gray";
39
				width = height = "15px";
40
				fontSize = "1px";
41
			}
42
			td.color = "#" + colors[i][j];
43
			td.onmouseover = function (e) {
44
				this.style.borderColor = "white";
45
			};
46
			td.onmouseout = function (e) {
47
				this.style.borderColor = "gray";
48
			};
49
			dojo.event.connect(td, "onmousedown", this, "onClick");
50
			td.innerHTML = "&nbsp;";
51
		}
52
	}
53
}, onClick:function (e) {
54
	this.onColorSelect(e.currentTarget.color);
55
	e.currentTarget.style.borderColor = "gray";
56
}, onColorSelect:function (color) {
57
}});
58