Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Details | Compare with Previous | 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.widget.ColorPalette");
14
dojo.require("dojo.widget.*");
15
dojo.require("dojo.html.layout");
16
dojo.require("dojo.html.display");
17
dojo.require("dojo.html.selection");
18
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 () {
19
	this.domNode = document.createElement("table");
20
	dojo.html.disableSelection(this.domNode);
21
	dojo.event.connect(this.domNode, "onmousedown", function (e) {
22
		e.preventDefault();
23
	});
24
	with (this.domNode) {
25
		cellPadding = "0";
26
		cellSpacing = "1";
27
		border = "1";
28
		style.backgroundColor = "white";
29
	}
30
	var colors = this._palettes[this.palette];
31
	for (var i = 0; i < colors.length; i++) {
32
		var tr = this.domNode.insertRow(-1);
33
		for (var j = 0; j < colors[i].length; j++) {
34
			if (colors[i][j].length == 3) {
35
				colors[i][j] = colors[i][j].replace(/(.)(.)(.)/, "$1$1$2$2$3$3");
36
			}
37
			var td = tr.insertCell(-1);
38
			with (td.style) {
39
				backgroundColor = "#" + colors[i][j];
40
				border = "1px solid gray";
41
				width = height = "15px";
42
				fontSize = "1px";
43
			}
44
			td.color = "#" + colors[i][j];
45
			td.onmouseover = function (e) {
46
				this.style.borderColor = "white";
47
			};
48
			td.onmouseout = function (e) {
49
				this.style.borderColor = "gray";
50
			};
51
			dojo.event.connect(td, "onmousedown", this, "onClick");
52
			td.innerHTML = "&nbsp;";
53
		}
54
	}
55
}, onClick:function (e) {
56
	this.onColorSelect(e.currentTarget.color);
57
	e.currentTarget.style.borderColor = "gray";
58
}, onColorSelect:function (color) {
59
}});
60