[ Index ] |
|
Code source de XOOPS 2.0.17.1 |
1 // Title: Tigra Color Picker 2 // URL: http://www.softcomplex.com/products/tigra_color_picker/ 3 // Version: 1.1 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 8 9 var TCP = new TColorPicker(); 10 11 function TCPopup(path, field, palette) { 12 this.path = path; 13 this.field = field; 14 this.initPalette = !palette || palette > 3 ? 3 : palette; 15 var w = 194, h = 240, 16 move = screen ? 17 ',left=' + ((screen.width - w) >> 1) + ',top=' + ((screen.height - h) >> 1) : '', 18 o_colWindow = window.open(this.path+'color-picker.html', null, "help=no,status=no,scrollbars=no,resizable=no" + move + ",width=" + w + ",height=" + h + ",dependent=yes", true); 19 o_colWindow.opener = window; 20 o_colWindow.focus(); 21 return false; 22 } 23 24 function TCBuildCell (R, G, B, w, h) { 25 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 } 27 28 function TCSelect(c) { 29 this.field.value = '#' + c.toUpperCase(); 30 this.field.style.backgroundColor = '#' + c.toUpperCase(); 31 this.win.close(); 32 } 33 34 function TCPaint(c, b_noPref) { 35 c = (b_noPref ? '' : '#') + c.toUpperCase(); 36 if (this.o_samp) 37 this.o_samp.innerHTML = '<font face=Tahoma size=2>' + c +' <font color=white>' + c + '</font></font>' 38 if(this.doc.layers) 39 this.sample.bgColor = c; 40 else { 41 if (this.sample.backgroundColor != null) this.sample.backgroundColor = c; 42 else if (this.sample.background != null) this.sample.background = c; 43 } 44 } 45 46 function TCGenerateSafe() { 47 var s = ''; 48 for (j = 0; j < 12; j ++) { 49 s += "<tr>"; 50 for (k = 0; k < 3; k ++) 51 for (i = 0; i <= 5; i ++) 52 s += this.bldCell(k * 51 + (j % 2) * 51 * 3, Math.floor(j / 2) * 51, i * 51, 8, 10); 53 s += "</tr>"; 54 } 55 return s; 56 } 57 58 function TCGenerateWind() { 59 var s = ''; 60 for (j = 0; j < 12; j ++) { 61 s += "<tr>"; 62 for (k = 0; k < 3; k ++) 63 for (i = 0; i <= 5; i++) 64 s += this.bldCell(i * 51, k * 51 + (j % 2) * 51 * 3, Math.floor(j / 2) * 51, 8, 10); 65 s += "</tr>"; 66 } 67 return s 68 } 69 function TCGenerateMac() { 70 var s = ''; 71 var c = 0,n = 1; 72 var r,g,b; 73 for (j = 0; j < 15; j ++) { 74 s += "<tr>"; 75 for (k = 0; k < 3; k ++) 76 for (i = 0; i <= 5; i++){ 77 if(j<12){ 78 s += this.bldCell( 255-(Math.floor(j / 2) * 51), 255-(k * 51 + (j % 2) * 51 * 3),255-(i * 51), 8, 10); 79 }else{ 80 if(n<=14){ 81 r = 255-(n * 17); 82 g=b=0; 83 }else if(n>14 && n<=28){ 84 g = 255-((n-14) * 17); 85 r=b=0; 86 }else if(n>28 && n<=42){ 87 b = 255-((n-28) * 17); 88 r=g=0; 89 }else{ 90 r=g=b=255-((n-42) * 17); 91 } 92 s += this.bldCell( r, g,b, 8, 10); 93 n++; 94 } 95 } 96 s += "</tr>"; 97 } 98 return s; 99 } 100 101 function TCGenerateGray() { 102 var s = ''; 103 for (j = 0; j <= 15; j ++) { 104 s += "<tr>"; 105 for (k = 0; k <= 15; k ++) { 106 g = Math.floor((k + j * 16) % 256); 107 s += this.bldCell(g, g, g, 9, 7); 108 } 109 s += '</tr>'; 110 } 111 return s 112 } 113 114 function TCDec2Hex(v) { 115 v = v.toString(16); 116 for(; v.length < 6; v = '0' + v); 117 return v; 118 } 119 120 function TCChgMode(v) { 121 for (var k in this.divs) this.hide(k); 122 this.show(v); 123 } 124 125 function TColorPicker(field) { 126 this.build0 = TCGenerateSafe; 127 this.build1 = TCGenerateWind; 128 this.build2 = TCGenerateGray; 129 this.build3 = TCGenerateMac; 130 this.show = document.layers ? 131 function (div) { this.divs[div].visibility = 'show' } : 132 function (div) { this.divs[div].visibility = 'visible' }; 133 this.hide = document.layers ? 134 function (div) { this.divs[div].visibility = 'hide' } : 135 function (div) { this.divs[div].visibility = 'hidden' }; 136 // event handlers 137 this.C = TCChgMode; 138 this.S = TCSelect; 139 this.P = TCPaint; 140 this.popup = TCPopup; 141 this.draw = TCDraw; 142 this.dec2hex = TCDec2Hex; 143 this.bldCell = TCBuildCell; 144 this.divs = []; 145 } 146 147 function TCDraw(o_win, o_doc) { 148 this.win = o_win; 149 this.doc = o_doc; 150 var 151 s_tag_openT = o_doc.layers ? 152 'layer visibility=hidden top=30 left=5 width=182' : 153 'div style=visibility:hidden;position:absolute;left:6px;top:30px;width:182px;height:0', 154 s_tag_openS = o_doc.layers ? 'layer top=32 left=6' : 'div', 155 s_tag_close = o_doc.layers ? 'layer' : 'div' 156 157 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 + '>'); 158 this.sample = o_doc.layers ? o_doc.layers['sam'] : 159 o_doc.getElementById ? o_doc.getElementById('sam').style : o_doc.all['sam'].style 160 161 for (var k = 0; k < 4; k ++) { 162 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 + '>'); 163 this.divs[k] = o_doc.layers 164 ? o_doc.layers['p' + k] : o_doc.all 165 ? o_doc.all['p' + k].style : o_doc.getElementById('p' + k).style 166 } 167 if (!o_doc.layers && o_doc.body.innerHTML) 168 this.o_samp = o_doc.all 169 ? o_doc.all.samp : o_doc.getElementById('samp'); 170 this.C(this.initPalette); 171 if (this.field.value) this.P(this.field.value, true) 172 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Nov 25 11:44:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |