1
// Title: Tigra Color Picker
2
// URL: http://www.softcomplex.com/products/tigra_color_picker/
4
// Date: 06/26/2003 (mm/dd/yyyy)
5
// Note: Permission given to use this script in ANY kind of applications if
6
// header lines are left unchanged.
7
// Note: Script consists of two files: picker.js and picker.html
9
var TCP = new TColorPicker();
11
function TCPopup(field, palette) {
13
this.initPalette = !palette || palette > 3 ? 0 : palette;
16
',left=' + ((screen.width - w) >> 1) + ',top=' + ((screen.height - h) >> 1) : '',
17
o_colWindow = window.open('picker.vm', null, "help=no,status=no,scrollbars=no,resizable=no" + move + ",width=" + w + ",height=" + h + ",dependent=yes", true);
18
o_colWindow.opener = window;
22
function TCBuildCell (R, G, B, w, h) {
23
return '<td bgcolor="#' + this.dec2hex((R << 16) + (G << 8) + B) + '"><a href="javascript:P.S(\'' + this.dec2hex((R << 16) + (G << 8) + B) + '\')" onmouseover="P.P(\'' + this.dec2hex((R << 16) + (G << 8) + B) + '\')"><img src="pixel.gif" width="' + w + '" height="' + h + '" border="0"></a></td>';
26
function TCSelect(c) {
27
this.field.value = c.toUpperCase();
28
this.field.style.background='#' + c.toUpperCase();
32
function TCPaint(c, b_noPref) {
33
c = (b_noPref ? '' : '#') + c.toUpperCase();
35
this.o_samp.innerHTML = '<font face=Tahoma size=2>' + c +' <font color=white>' + c + '</font></font>'
37
this.sample.bgColor = c;
39
if (this.sample.backgroundColor != null) this.sample.backgroundColor = c;
40
else if (this.sample.background != null) this.sample.background = c;
44
function TCGenerateSafe() {
46
for (j = 0; j < 12; j ++) {
48
for (k = 0; k < 3; k ++)
49
for (i = 0; i <= 5; i ++)
50
s += this.bldCell(k * 51 + (j % 2) * 51 * 3, Math.floor(j / 2) * 51, i * 51, 8, 10);
56
function TCGenerateWind() {
58
for (j = 0; j < 12; j ++) {
60
for (k = 0; k < 3; k ++)
61
for (i = 0; i <= 5; i++)
62
s += this.bldCell(i * 51, k * 51 + (j % 2) * 51 * 3, Math.floor(j / 2) * 51, 8, 10);
67
function TCGenerateMac() {
71
for (j = 0; j < 15; j ++) {
73
for (k = 0; k < 3; k ++)
74
for (i = 0; i <= 5; i++){
76
s += this.bldCell( 255-(Math.floor(j / 2) * 51), 255-(k * 51 + (j % 2) * 51 * 3),255-(i * 51), 8, 10);
81
}else if(n>14 && n<=28){
82
g = 255-((n-14) * 17);
84
}else if(n>28 && n<=42){
85
b = 255-((n-28) * 17);
88
r=g=b=255-((n-42) * 17);
90
s += this.bldCell( r, g,b, 8, 10);
99
function TCGenerateGray() {
101
for (j = 0; j <= 15; j ++) {
103
for (k = 0; k <= 15; k ++) {
104
g = Math.floor((k + j * 16) % 256);
105
s += this.bldCell(g, g, g, 9, 7);
112
function TCDec2Hex(v) {
114
for(; v.length < 6; v = '0' + v);
118
function TCChgMode(v) {
119
for (var k in this.divs) this.hide(k);
123
function TColorPicker(field) {
124
this.build0 = TCGenerateSafe;
125
this.build1 = TCGenerateWind;
126
this.build2 = TCGenerateGray;
127
this.build3 = TCGenerateMac;
128
this.show = document.layers ?
129
function (div) { this.divs[div].visibility = 'show' } :
130
function (div) { this.divs[div].visibility = 'visible' };
131
this.hide = document.layers ?
132
function (div) { this.divs[div].visibility = 'hide' } :
133
function (div) { this.divs[div].visibility = 'hidden' };
138
this.popup = TCPopup;
140
this.dec2hex = TCDec2Hex;
141
this.bldCell = TCBuildCell;
145
function TCDraw(o_win, o_doc) {
149
s_tag_openT = o_doc.layers ?
150
'layer visibility=hidden top=54 left=5 width=182' :
151
'div style=visibility:hidden;position:absolute;left:6px;top:54px;width:182px;height:0',
152
s_tag_openS = o_doc.layers ? 'layer top=32 left=6' : 'div',
153
s_tag_close = o_doc.layers ? 'layer' : 'div'
155
this.doc.write('<' + s_tag_openS + ' id=sam name=sam><table cellpadding=0 cellspacing=0 border=1 width=181 align=center class=bd><tr><td align=center height=18><div id="samp"><font face=Tahoma size=2>sample <font color=white>sample</font></font></div></td></tr></table></' + s_tag_close + '>');
156
this.sample = o_doc.layers ? o_doc.layers['sam'] :
157
o_doc.getElementById ? o_doc.getElementById('sam').style : o_doc.all['sam'].style
159
for (var k = 0; k < 4; k ++) {
160
this.doc.write('<' + s_tag_openT + ' id="p' + k + '" name="p' + k + '"><table cellpadding=0 cellspacing=0 border=1 align=center>' + this['build' + k]() + '</table></' + s_tag_close + '>');
161
this.divs[k] = o_doc.layers
162
? o_doc.layers['p' + k] : o_doc.all
163
? o_doc.all['p' + k].style : o_doc.getElementById('p' + k).style
165
if (!o_doc.layers && o_doc.body.innerHTML)
166
this.o_samp = o_doc.all
167
? o_doc.all.samp : o_doc.getElementById('samp');
168
this.C(this.initPalette);
169
if (this.field.value) this.P(this.field.value, true)