Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/modules/ColorPicker/ColorPicker.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/modules/ColorPicker/ColorPicker.js,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-templating/www/resources/xinha-nightly/modules/ColorPicker/ColorPicker.js 13 May 2008 18:53:45 -0000 1.5 +++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/modules/ColorPicker/ColorPicker.js 16 Jan 2009 09:05:46 -0000 1.6 @@ -1,624 +1,2 @@ -/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */ -/* This file is part of version 0.95 released Mon, 12 May 2008 17:33:15 +0200 */ -/* The URL of the most recent version of this file is http://svn.xinha.webfactional.com/trunk/modules/ColorPicker/ColorPicker.js */ -ColorPicker._pluginInfo={name:"colorPicker",version:"$LastChangedRevision:998 $".replace(/^[^:]*:\s*(.*)\s*\$$/,"$1"),developer:"James Sleeman",developer_url:"http://www.gogo.co.nz/",c_owner:"Gogo Internet Services",license:"htmlArea",sponsor:"Gogo Internet Services",sponsor_url:"http://www.gogo.co.nz/"}; -function ColorPicker(){ -} -try{ -if(window.opener&&window.opener.Xinha){ -var openerColorPicker=window.opener.Xinha.colorPicker; -Xinha._addEvent(window,"unload",function(){ -Xinha.colorPicker=openerColorPicker; -}); -} -} -catch(e){ -} -Xinha.colorPicker=function(_1){ -if(Xinha.colorPicker.savedColors.length===0){ -Xinha.colorPicker.loadColors(); -} -this.is_ie_6=(Xinha.is_ie&&Xinha.ie_version<7); -var _2=this; -var _3=false; -var _4=false; -var _5=0; -var _6=0; -this.callback=_1.callback?_1.callback:function(_7){ -alert("You picked "+_7); -}; -this.websafe=_1.websafe?_1.websafe:false; -this.savecolors=_1.savecolors?_1.savecolors:20; -this.cellsize=parseInt(_1.cellsize?_1.cellsize:"10px",10); -this.side=_1.granularity?_1.granularity:18; -var _8=this.side+1; -var _9=this.side-1; -this.value=1; -this.saved_cells=null; -this.table=document.createElement("table"); -this.table.className="dialog"; -this.table.cellSpacing=this.table.cellPadding=0; -this.table.onmouseup=function(){ -_3=false; -_4=false; -}; -this.tbody=document.createElement("tbody"); -this.table.appendChild(this.tbody); -this.table.style.border="1px solid WindowFrame"; -this.table.style.zIndex="1050"; -var tr=document.createElement("tr"); -var td=document.createElement("td"); -td.colSpan=this.side; -td.className="title"; -td.style.fontFamily="small-caption,caption,sans-serif"; -td.style.fontSize="x-small"; -td.unselectable="on"; -td.style.MozUserSelect="none"; -td.style.cursor="default"; -td.appendChild(document.createTextNode(Xinha._lc("Click a color..."))); -td.style.borderBottom="1px solid WindowFrame"; -tr.appendChild(td); -td=null; -var td=document.createElement("td"); -td.className="title"; -td.colSpan=2; -td.style.fontFamily="Tahoma,Verdana,sans-serif"; -td.style.borderBottom="1px solid WindowFrame"; -td.style.paddingRight="0"; -tr.appendChild(td); -var _c=document.createElement("div"); -_c.title=Xinha._lc("Close"); -_c.className="buttonColor"; -_c.style.height="11px"; -_c.style.width="11px"; -_c.style.cursor="pointer"; -_c.onclick=function(){ -_2.close(); -}; -_c.appendChild(document.createTextNode("\xd7")); -_c.align="center"; -_c.style.verticalAlign="top"; -_c.style.position="relative"; -_c.style.cssFloat="right"; -_c.style.styleFloat="right"; -_c.style.padding="0"; -_c.style.margin="2px"; -_c.style.backgroundColor="transparent"; -_c.style.fontSize="11px"; -if(!Xinha.is_ie){ -_c.style.lineHeight="9px"; -} -_c.style.letterSpacing="0"; -td.appendChild(_c); -this.tbody.appendChild(tr); -_c=tr=td=null; -this.constrain_cb=document.createElement("input"); -this.constrain_cb.type="checkbox"; -this.chosenColor=document.createElement("input"); -this.chosenColor.type="text"; -this.chosenColor.maxLength=7; -this.chosenColor.style.width="50px"; -this.chosenColor.style.fontSize="11px"; -this.chosenColor.onchange=function(){ -if(/#[0-9a-f]{6,6}/i.test(this.value)){ -_2.backSample.style.backgroundColor=this.value; -_2.foreSample.style.color=this.value; -} -}; -this.backSample=document.createElement("div"); -this.backSample.appendChild(document.createTextNode("\xa0")); -this.backSample.style.fontWeight="bold"; -this.backSample.style.fontFamily="small-caption,caption,sans-serif"; -this.backSample.fontSize="x-small"; -this.foreSample=document.createElement("div"); -this.foreSample.appendChild(document.createTextNode(Xinha._lc("Sample"))); -this.foreSample.style.fontWeight="bold"; -this.foreSample.style.fontFamily="small-caption,caption,sans-serif"; -this.foreSample.fontSize="x-small"; -function toHex(_d){ -var h=_d.toString(16); -if(h.length<2){ -h="0"+h; -} -return h; -} -function tupleToColor(_f){ -return "#"+toHex(_f.red)+toHex(_f.green)+toHex(_f.blue); -} -function nearestPowerOf(num,_11){ -return Math.round(Math.round(num/_11)*_11); -} -function doubleHexDec(dec){ -return parseInt(dec.toString(16)+dec.toString(16),16); -} -function rgbToWebsafe(_13){ -_13.red=doubleHexDec(nearestPowerOf(parseInt(toHex(_13.red).charAt(0),16),3)); -_13.blue=doubleHexDec(nearestPowerOf(parseInt(toHex(_13.blue).charAt(0),16),3)); -_13.green=doubleHexDec(nearestPowerOf(parseInt(toHex(_13.green).charAt(0),16),3)); -return _13; -} -function hsvToRGB(h,s,v){ -var _17; -if(s===0){ -_17={red:v,green:v,blue:v}; -}else{ -h/=60; -var i=Math.floor(h); -var f=h-i; -var p=v*(1-s); -var q=v*(1-s*f); -var t=v*(1-s*(1-f)); -switch(i){ -case 0: -_17={red:v,green:t,blue:p}; -break; -case 1: -_17={red:q,green:v,blue:p}; -break; -case 2: -_17={red:p,green:v,blue:t}; -break; -case 3: -_17={red:p,green:q,blue:v}; -break; -case 4: -_17={red:t,green:p,blue:v}; -break; -default: -_17={red:v,green:p,blue:q}; -break; -} -} -_17.red=Math.ceil(_17.red*255); -_17.green=Math.ceil(_17.green*255); -_17.blue=Math.ceil(_17.blue*255); -return _17; -} -var _1d=this; -function closeOnBodyClick(ev){ -ev=ev?ev:window.event; -el=ev.target?ev.target:ev.srcElement; -do{ -if(el==_1d.table){ -return; -} -}while(el=el.parentNode); -_1d.close(); -} -this.open=function(_1f,_20,_21){ -this.table.style.display=""; -this.pick_color(); -if(_21&&/#[0-9a-f]{6,6}/i.test(_21)){ -this.chosenColor.value=_21; -this.backSample.style.backgroundColor=_21; -this.foreSample.style.color=_21; -} -Xinha._addEvent(document.body,"mousedown",closeOnBodyClick); -this.table.style.position="absolute"; -var e=_20; -var top=0; -var _24=0; -do{ -if(e.style.position=="fixed"){ -this.table.style.position="fixed"; -} -top+=e.offsetTop; -_24+=e.offsetLeft; -e=e.offsetParent; -}while(e); -var x,y; -if(/top/.test(_1f)||(top+this.table.offsetHeight>document.body.offsetHeight)){ -if(top-this.table.offsetHeight>0){ -this.table.style.top=(top-this.table.offsetHeight)+"px"; -}else{ -this.table.style.top=0; -} -}else{ -this.table.style.top=(top+_20.offsetHeight)+"px"; -} -if(/left/.test(_1f)||(_24+this.table.offsetWidth>document.body.offsetWidth)){ -if(_24-(this.table.offsetWidth-_20.offsetWidth)>0){ -this.table.style.left=(_24-(this.table.offsetWidth-_20.offsetWidth))+"px"; -}else{ -this.table.style.left=0; -} -}else{ -this.table.style.left=_24+"px"; -} -if(this.is_ie_6){ -this.iframe.style.top=this.table.style.top; -this.iframe.style.left=this.table.style.left; -} -}; -function pickCell(_26){ -_2.chosenColor.value=_26.colorCode; -_2.backSample.style.backgroundColor=_26.colorCode; -_2.foreSample.style.color=_26.colorCode; -if((_26.hue>=195&&_26.saturation>0.5)||(_26.hue===0&&_26.saturation===0&&_26.value<0.5)||(_26.hue!==0&&_2.value<0.75)){ -_26.style.borderColor="#fff"; -}else{ -_26.style.borderColor="#000"; -} -_5=_26.thisrow; -_6=_26.thiscol; -} -function pickValue(_27){ -if(_2.value<0.5){ -_27.style.borderColor="#fff"; -}else{ -_27.style.borderColor="#000"; -} -_9=_27.thisrow; -_8=_27.thiscol; -_2.chosenColor.value=_2.saved_cells[_5][_6].colorCode; -_2.backSample.style.backgroundColor=_2.saved_cells[_5][_6].colorCode; -_2.foreSample.style.color=_2.saved_cells[_5][_6].colorCode; -} -function unpickCell(row,col){ -_2.saved_cells[row][col].style.borderColor=_2.saved_cells[row][col].colorCode; -} -this.pick_color=function(){ -var _2a,cols; -var _2b=this; -var _2c=359/(this.side); -var _2d=1/(this.side-1); -var _2e=1/(this.side-1); -var _2f=this.constrain_cb.checked; -if(this.saved_cells===null){ -this.saved_cells=[]; -for(var row=0;row=195&&_41.saturation>0.5)||(_41.hue===0&&_41.saturation===0&&_41.value<0.5)||(_41.hue!==0&&_2b.value<0.75)){ -_41.style.borderColor="#fff"; -}else{ -_41.style.borderColor="#000"; -} -} -}; -this.close=function(){ -Xinha._removeEvent(document.body,"mousedown",closeOnBodyClick); -this.table.style.display="none"; -if(this.is_ie_6){ -if(this.iframe){ -this.iframe.style.display="none"; -} -} -}; -}; -Xinha.colorPicker.savedColors=[]; -Xinha.colorPicker.remember=function(_42,_43){ -for(var i=Xinha.colorPicker.savedColors.length;i--;){ -if(Xinha.colorPicker.savedColors[i]==_42){ -return false; -} -} -Xinha.colorPicker.savedColors.splice(0,0,_42); -Xinha.colorPicker.savedColors=Xinha.colorPicker.savedColors.slice(0,_43); -var _45=new Date(); -_45.setMonth(_45.getMonth()+1); -document.cookie="XinhaColorPicker="+escape(Xinha.colorPicker.savedColors.join("-"))+";expires="+_45.toGMTString(); -return true; -}; -Xinha.colorPicker.loadColors=function(){ -var _46=document.cookie.indexOf("XinhaColorPicker"); -if(_46!=-1){ -var _47=(document.cookie.indexOf("=",_46)+1); -var end=document.cookie.indexOf(";",_46); -if(end==-1){ -end=document.cookie.length; -} -Xinha.colorPicker.savedColors=unescape(document.cookie.substring(_47,end)).split("-"); -} -}; -Xinha.colorPicker.InputBinding=function(_49,_4a){ -var doc=_49.ownerDocument; -var _4c=doc.createElement("span"); -_4c.className="buttonColor"; -var _4d=this.chooser=doc.createElement("span"); -_4d.className="chooser"; -if(_49.value){ -_4d.style.backgroundColor=_49.value; -} -_4d.onmouseover=function(){ -_4d.className="chooser buttonColor-hilite"; -}; -_4d.onmouseout=function(){ -_4d.className="chooser"; -}; -_4d.appendChild(doc.createTextNode("\xa0")); -_4c.appendChild(_4d); -var _4e=doc.createElement("span"); -_4e.className="nocolor"; -_4e.onmouseover=function(){ -_4e.className="nocolor buttonColor-hilite"; -_4e.style.color="#f00"; -}; -_4e.onmouseout=function(){ -_4e.className="nocolor"; -_4e.style.color="#000"; -}; -_4e.onclick=function(){ -_49.value=""; -_4d.style.backgroundColor=""; -}; -_4e.appendChild(doc.createTextNode("\xd7")); -_4c.appendChild(_4e); -_49.parentNode.insertBefore(_4c,_49.nextSibling); -Xinha._addEvent(_49,"change",function(){ -_4d.style.backgroundColor=this.value; -}); -_4a=(_4a)?Xinha.cloneObject(_4a):{cellsize:"5px"}; -_4a.callback=(_4a.callback)?_4a.callback:function(_4f){ -_4d.style.backgroundColor=_4f; -_49.value=_4f; -}; -_4d.onclick=function(){ -var _50=new Xinha.colorPicker(_4a); -_50.open("",_4d,_49.value); -}; -Xinha.freeLater(this,"chooser"); -}; -Xinha.colorPicker.InputBinding.prototype.setColor=function(_51){ -this.chooser.style.backgroundColor=_51; -}; - +/* This compressed file is part of Xinha. For uncomressed sources, forum, and bug reports, go to xinha.org */ +ColorPicker._pluginInfo={name:"colorPicker",version:"$LastChangedRevision: 1084 $".replace(/^[^:]*:\s*(.*)\s*\$$/,"$1"),developer:"James Sleeman",developer_url:"http://www.gogo.co.nz/",c_owner:"Gogo Internet Services",license:"htmlArea",sponsor:"Gogo Internet Services",sponsor_url:"http://www.gogo.co.nz/"};function ColorPicker(){}try{if(window.opener&&window.opener.Xinha){var openerColorPicker=window.opener.Xinha.colorPicker;Xinha._addEvent(window,"unload",function(){Xinha.colorPicker=openerColorPicker})}}catch(e){}Xinha.colorPicker=function(t){if(Xinha.colorPicker.savedColors.length===0){Xinha.colorPicker.loadColors()}this.is_ie_6=(Xinha.is_ie&&Xinha.ie_version<7);var i=this;var c=false;var d=false;var w=0;var u=0;this.callback=t.callback?t.callback:function(x){alert("You picked "+x)};this.websafe=t.websafe?t.websafe:false;this.savecolors=t.savecolors?t.savecolors:20;this.cellsize=parseInt(t.cellsize?t.cellsize:"10px",10);this.side=t.granularity?t.granularity:18;var h=this.side+1;var k=this.side-1;this.value=1;this.saved_cells=null;this.table=document.createElement("table");this.table.className="dialog";this.table.cellSpacing=this.table.cellPadding=0;this.table.onmouseup=function(){c=false;d=false};this.tbody=document.createElement("tbody");this.table.appendChild(this.tbody);this.table.style.border="1px solid WindowFrame";this.table.style.zIndex="1050";var b=document.createElement("tr");var g=document.createElement("td");g.colSpan=this.side;g.className="title";g.style.fontFamily="small-caption,caption,sans-serif";g.style.fontSize="x-small";g.unselectable="on";g.style.MozUserSelect="none";g.style.cursor="default";g.appendChild(document.createTextNode(Xinha._lc("Click a color...")));g.style.borderBottom="1px solid WindowFrame";b.appendChild(g);g=null;var g=document.createElement("td");g.className="title";g.colSpan=2;g.style.fontFamily="Tahoma,Verdana,sans-serif";g.style.borderBottom="1px solid WindowFrame";g.style.paddingRight="0";b.appendChild(g);var m=document.createElement("div");m.title=Xinha._lc("Close");m.className="buttonColor";m.style.height="11px";m.style.width="11px";m.style.cursor="pointer";m.onclick=function(){i.close()};m.appendChild(document.createTextNode("\u00D7"));m.align="center";m.style.verticalAlign="top";m.style.position="relative";m.style.cssFloat="right";m.style.styleFloat="right";m.style.padding="0";m.style.margin="2px";m.style.backgroundColor="transparent";m.style.fontSize="11px";if(!Xinha.is_ie){m.style.lineHeight="9px"}m.style.letterSpacing="0";g.appendChild(m);this.tbody.appendChild(b);m=b=g=null;this.constrain_cb=document.createElement("input");this.constrain_cb.type="checkbox";this.chosenColor=document.createElement("input");this.chosenColor.type="text";this.chosenColor.maxLength=7;this.chosenColor.style.width="50px";this.chosenColor.style.fontSize="11px";this.chosenColor.onchange=function(){if(/#[0-9a-f]{6,6}/i.test(this.value)){i.backSample.style.backgroundColor=this.value;i.foreSample.style.color=this.value}};this.backSample=document.createElement("div");this.backSample.appendChild(document.createTextNode("\u00A0"));this.backSample.style.fontWeight="bold";this.backSample.style.fontFamily="small-caption,caption,sans-serif";this.backSample.fontSize="x-small";this.foreSample=document.createElement("div");this.foreSample.appendChild(document.createTextNode(Xinha._lc("Sample")));this.foreSample.style.fontWeight="bold";this.foreSample.style.fontFamily="small-caption,caption,sans-serif";this.foreSample.fontSize="x-small";function q(y){var x=y.toString(16);if(x.length<2){x="0"+x}return x}function p(x){return"#"+q(x.red)+q(x.green)+q(x.blue)}function v(x,y){return Math.round(Math.round(x/y)*y)}function f(x){return parseInt(x.toString(16)+x.toString(16),16)}function s(x){x.red=f(v(parseInt(q(x.red).charAt(0),16),3));x.blue=f(v(parseInt(q(x.blue).charAt(0),16),3));x.green=f(v(parseInt(q(x.green).charAt(0),16),3));return x}function l(B,F,D){var x;if(F===0){x={red:D,green:D,blue:D}}else{B/=60;var A=Math.floor(B);var C=B-A;var z=D*(1-F);var y=D*(1-F*C);var E=D*(1-F*(1-C));switch(A){case 0:x={red:D,green:E,blue:z};break;case 1:x={red:y,green:D,blue:z};break;case 2:x={red:z,green:D,blue:E};break;case 3:x={red:z,green:y,blue:D};break;case 4:x={red:E,green:z,blue:D};break;default:x={red:D,green:z,blue:y};break}}x.red=Math.ceil(x.red*255);x.green=Math.ceil(x.green*255);x.blue=Math.ceil(x.blue*255);return x}var o=this;function a(x){x=x?x:window.event;el=x.target?x.target:x.srcElement;do{if(el==o.table){return}}while(el=el.parentNode);o.close()}this.open=function(G,A,B){this.table.style.display="";this.pick_color();if(B&&/#[0-9a-f]{6,6}/i.test(B)){this.chosenColor.value=B;this.backSample.style.backgroundColor=B;this.foreSample.style.color=B}Xinha._addEvent(document.body,"mousedown",a);this.table.style.position="absolute";var E=A;var D=0;var C=0;do{if(E.style.position=="fixed"){this.table.style.position="fixed"}D+=E.offsetTop-E.scrollTop;C+=E.offsetLeft-E.scrollLeft;E=E.offsetParent}while(E);var z,F;if(/top/.test(G)||(D+this.table.offsetHeight>document.body.offsetHeight)){if(D-this.table.offsetHeight>0){this.table.style.top=(D-this.table.offsetHeight)+"px"}else{this.table.style.top=0}}else{this.table.style.top=(D+A.offsetHeight)+"px"}if(/left/.test(G)||(C+this.table.offsetWidth>document.body.offsetWidth)){if(C-(this.table.offsetWidth-A.offsetWidth)>0){this.table.style.left=(C-(this.table.offsetWidth-A.offsetWidth))+"px"}else{this.table.style.left=0}}else{this.table.style.left=C+"px"}if(this.is_ie_6){this.iframe.style.top=this.table.style.top;this.iframe.style.left=this.table.style.left}};function n(x){i.chosenColor.value=x.colorCode;i.backSample.style.backgroundColor=x.colorCode;i.foreSample.style.color=x.colorCode;if((x.hue>=195&&x.saturation>0.5)||(x.hue===0&&x.saturation===0&&x.value<0.5)||(x.hue!==0&&i.value<0.75)){x.style.borderColor="#fff"}else{x.style.borderColor="#000"}w=x.thisrow;u=x.thiscol}function j(x){if(i.value<0.5){x.style.borderColor="#fff"}else{x.style.borderColor="#000"}k=x.thisrow;h=x.thiscol;i.chosenColor.value=i.saved_cells[w][u].colorCode;i.backSample.style.backgroundColor=i.saved_cells[w][u].colorCode;i.foreSample.style.color=i.saved_cells[w][u].colorCode}function r(y,x){i.saved_cells[y][x].style.borderColor=i.saved_cells[y][x].colorCode}this.pick_color=function(){var K,L;var J=this;var R=359/(this.side);var B=1/(this.side-1);var I=1/(this.side-1);var Q=this.constrain_cb.checked;if(this.saved_cells===null){this.saved_cells=[];for(var C=0;C=195&&D.saturation>0.5)||(D.hue===0&&D.saturation===0&&D.value<0.5)||(D.hue!==0&&J.value<0.75)){D.style.borderColor="#fff"}else{D.style.borderColor="#000"}}};this.close=function(){Xinha._removeEvent(document.body,"mousedown",a);this.table.style.display="none";if(this.is_ie_6){if(this.iframe){this.iframe.style.display="none"}}}};Xinha.colorPicker.savedColors=[];Xinha.colorPicker.remember=function(a,c){for(var b=Xinha.colorPicker.savedColors.length;b--;){if(Xinha.colorPicker.savedColors[b]==a){return false}}Xinha.colorPicker.savedColors.splice(0,0,a);Xinha.colorPicker.savedColors=Xinha.colorPicker.savedColors.slice(0,c);var d=new Date();d.setMonth(d.getMonth()+1);document.cookie="XinhaColorPicker="+escape(Xinha.colorPicker.savedColors.join("-"))+";expires="+d.toGMTString();return true};Xinha.colorPicker.loadColors=function(){var b=document.cookie.indexOf("XinhaColorPicker");if(b!=-1){var c=(document.cookie.indexOf("=",b)+1);var a=document.cookie.indexOf(";",b);if(a==-1){a=document.cookie.length}Xinha.colorPicker.savedColors=unescape(document.cookie.substring(c,a)).split("-")}};Xinha.colorPicker.InputBinding=function(b,c){var g=b.ownerDocument;var a=g.createElement("span");a.className="buttonColor";var d=this.chooser=g.createElement("span");d.className="chooser";if(b.value){d.style.backgroundColor=b.value}d.onmouseover=function(){d.className="chooser buttonColor-hilite"};d.onmouseout=function(){d.className="chooser"};d.appendChild(g.createTextNode("\u00a0"));a.appendChild(d);var f=g.createElement("span");f.className="nocolor";f.onmouseover=function(){f.className="nocolor buttonColor-hilite";f.style.color="#f00"};f.onmouseout=function(){f.className="nocolor";f.style.color="#000"};f.onclick=function(){b.value="";d.style.backgroundColor=""};f.appendChild(g.createTextNode("\u00d7"));a.appendChild(f);b.parentNode.insertBefore(a,b.nextSibling);Xinha._addEvent(b,"change",function(){d.style.backgroundColor=this.value});c=(c)?Xinha.cloneObject(c):{cellsize:"5px"};c.callback=(c.callback)?c.callback:function(h){d.style.backgroundColor=h;b.value=h};d.onclick=function(){var h=new Xinha.colorPicker(c);h.open("",d,b.value)};Xinha.freeLater(this,"chooser")};Xinha.colorPicker.InputBinding.prototype.setColor=function(a){this.chooser.style.backgroundColor=a}; \ No newline at end of file