BVB Source Codes

Pcook CMS bubble guest v3.0 SDCMS version Show color_picker.js Source code

Return Download Pcook CMS bubble guest v3.0 SDCMS version: download color_picker.js Source code - Download Pcook CMS bubble guest v3.0 SDCMS version Source code - Type:.js
  1. /*** Color Picker Object ***/
  2. var arrColorPickerObjects=[];
  3. function ColorPicker(sName,sParent)
  4.     {
  5.     this.oParent=sParent;
  6.     if(sParent)
  7.         {
  8.         this.oName=sParent+"."+sName;
  9.         this.oRenderName=sName+sParent;
  10.         }
  11.     else
  12.         {
  13.         this.oName=sName;
  14.         this.oRenderName=sName;
  15.         }
  16.     arrColorPickerObjects.push(this.oName);
  17.  
  18.     this.url="color_picker.htm";
  19.     this.onShow=function(){return true;};
  20.     this.onHide=function(){return true;};
  21.     this.onPickColor=function(){return true;};
  22.     this.onRemoveColor=function(){return true;};
  23.     this.onMoreColor=function(){return true;};  
  24.     this.show=showColorPicker;
  25.     this.hide=hideColorPicker;
  26.     this.hideAll=hideColorPickerAll;
  27.     this.color;
  28.     this.customColors=[];
  29.     this.refreshCustomColor=refreshCustomColor;
  30.     this.isActive=false;
  31.     this.txtCustomColors="Custom Colors";
  32.     this.txtMoreColors="More Colors...";
  33.     this.align="left";
  34.     this.currColor="#ffffff";//default current color
  35.     this.RENDER=drawColorPicker;
  36.     }
  37.    
  38. function drawColorPicker()
  39.     {  
  40.     var arrColors=[["#800000","#8b4513","#006400","#2f4f4f","#000080","#4b0082","#800080","#000000"],
  41.                 ["#ff0000","#daa520","#6b8e23","#708090","#0000cd","#483d8b","#c71585","#696969"],
  42.                 ["#ff4500","#ffa500","#808000","#4682b4","#1e90ff","#9400d3","#ff1493","#a9a9a9"],
  43.                 ["#ff6347","#ffd700","#32cd32","#87ceeb","#00bfff","#9370db","#ff69b4","#dcdcdc"],
  44.                 ["#ffdab9","#ffffe0","#98fb98","#e0ffff","#87cefa","#e6e6fa","#dda0dd","#ffffff"]]
  45.     var sHTMLColor="<table id=dropColor"+this.oRenderName+" style=\"z-index:1;display:none;position:absolute;border:#9b95a6 1px solid;cursor:default;background-color:#E9E8F2;padding:2px\" unselectable=on cellpadding=0 cellspacing=0 width=145px><tr><td unselectable=on>"
  46.     sHTMLColor+="<table align=center cellpadding=0 cellspacing=0 border=0 unselectable=on>";
  47.     for(var i=0;i<arrColors.length;i++)
  48.         {
  49.         sHTMLColor+="<tr>";
  50.         for(var j=0;j<arrColors[i].length;j++)
  51.             sHTMLColor+="<td onclick=\""+this.oName+".color='"+arrColors[i][j]+"';"+this.oName+".onPickColor();"+this.oName+".currColor='"+arrColors[i][j]+"';"+this.oName+".hideAll()\" onmouseover=\"this.style.border='#777777 1px solid'\" onmouseout=\"this.style.border='#E9E8F2 1px solid'\" style=\"cursor:default;padding:1px;border:#E9E8F2 1px solid;\" unselectable=on>"+
  52.                 "<table style='margin:0px;width:13px;height:13px;background:"+arrColors[i][j]+";border:white 1px solid' cellpadding=0 cellspacing=0 unselectable=on>"+
  53.                 "<tr><td unselectable=on></td></tr>"+
  54.                 "</table></td>";
  55.         sHTMLColor+="</tr>";        
  56.         }
  57.    
  58.     //~~~ custom colors ~~~~
  59.     sHTMLColor+="<tr><td colspan=8 id=idCustomColor"+this.oRenderName+"></td></tr>";
  60.    
  61.     //~~~ remove color & more colors ~~~~
  62.     sHTMLColor+= "<tr>";
  63.     sHTMLColor+= "<td unselectable=on>"+
  64.         "<table style='margin-left:1px;width:14px;height:14px;background:#E9E8F2;' cellpadding=0 cellspacing=0 unselectable=on>"+
  65.         "<tr><td onclick=\""+this.oName+".onRemoveColor();"+this.oName+".currColor='';"+this.oName+".hideAll()\" onmouseover=\"this.style.border='#777777 1px solid'\" onmouseout=\"this.style.border='white 1px solid'\" style=\"cursor:default;padding:1px;border:white 1px solid;font-family:verdana;font-size:10px;font-color:black;line-height:9px;\" align=center valign=top unselectable=on>x</td></tr>"+
  66.         "</table></td>";
  67.     sHTMLColor+= "<td colspan=7 unselectable=on>"+
  68.         "<table style='margin:1px;width:117px;height:16px;background:#E9E8F2;border:white 1px solid' cellpadding=0 cellspacing=0 unselectable=on>"+
  69.         "<tr><td id='"+this.oName+"moreColTd' onclick=\""+this.oName+".onMoreColor();"+this.oName+".hideAll();modalDialogShow('"+this.url+"?" +this.oName+ "', 442, 380)\" onmouseover=\"this.style.border='#777777 1px solid';this.style.background='#8d9aa7';this.style.color='#ffffff'\" onmouseout=\"this.style.border='#E9E8F2 1px solid';this.style.background='#E9E8F2';this.style.color='#000000'\" style=\"cursor:default;font-family:verdana;font-size:9px;font-color:black;line-height:9px;padding:1px\" align=center valign=top nowrap unselectable=on>"+this.txtMoreColors+"</td></tr>"+
  70.         "</table></td>";
  71.     sHTMLColor+= "</tr>";
  72.    
  73.     sHTMLColor+= "</table>";            
  74.     sHTMLColor+="</td></tr></table>";
  75.     document.write(sHTMLColor);
  76.     }
  77.    
  78. function refreshCustomColor()
  79.     {
  80.     var arg = eval(dialogArgument[0]);
  81.     var arg2 = eval(dialogArgument[1]);
  82.     if(arg.oUtil)//[CUSTOM]
  83.         this.customColors=arg.oUtil.obj.customColors;//[CUSTOM] (Get from public definition)
  84.     else //text2.htm [CUSTOM]
  85.         this.customColors=arg2.oUtil.obj.customColors;//[CUSTOM] (Get from public definition)
  86.  
  87.     if(this.customColors.length==0)
  88.         {
  89.         document.getElementById("idCustomColor"+this.oRenderName).innerHTML="";
  90.         return;
  91.         }
  92.     sHTML="<table cellpadding=0 cellspacing=0 width=100%><tr><td colspan=8 style=\"font-family:verdana;font-size:9px;font-color:black;line-height:9px;padding:1\">"+this.txtCustomColors+":</td></tr></table>"
  93.     sHTML+="<table cellpadding=0 cellspacing=0><tr>";  
  94.     for(var i=0;i<this.customColors.length;i++)
  95.         {
  96.         if(i<22)
  97.             {
  98.             if(i==8||i==16||i==24||i==32)sHTML+="</tr></table><table cellpadding=0 cellspacing=0><tr>"  
  99.             sHTML+="<td onclick=\""+this.oName+".color='"+this.customColors[i]+"';"+this.oName+".onPickColor()\" onmouseover=\"this.style.border='#777777 1px solid'\" onmouseout=\"this.style.border='#E9E8F2 1px solid'\" style=\"cursor:default;padding:1px;border:#E9E8F2 1px solid;\" unselectable=on>"+
  100.                 "   <table  style='margin:0;width:13;height:13;background:"+this.customColors[i]+";border:white 1px solid' cellpadding=0 cellspacing=0 unselectable=on>"+
  101.                 "   <tr><td unselectable=on></td></tr>"+
  102.                 "   </table>"+
  103.                 "</td>";
  104.             }          
  105.         }
  106.     sHTML+="</tr></table>";
  107.     document.getElementById("idCustomColor"+this.oRenderName).innerHTML=sHTML;
  108.     }
  109. function showColorPicker(oEl)
  110.     {
  111.     this.onShow();
  112.    
  113.     this.hideAll();
  114.  
  115.     var box=document.getElementById("dropColor"+this.oRenderName);
  116.  
  117.     //remove hilite
  118.     var allTds = box.getElementsByTagName("TD");
  119.     for (var i = 0; i<allTds.length; i++) {
  120.         allTds[i].style.border="#E9E8F2 1px solid";
  121.         if (allTds[i].id==this.oName+"moreColTd") {
  122.             allTds[i].style.border="#E9E8F2 1px solid";
  123.             allTds[i].style.background="#E9E8F2";
  124.             allTds[i].style.color="#000000";
  125.         }
  126.     }
  127.  
  128.     box.style.display="block";
  129.     var nTop=0;
  130.     var nLeft=0;
  131.  
  132.     oElTmp=oEl;
  133.     while(oElTmp.tagName!="BODY" && oElTmp.tagName!="HTML")
  134.         {
  135.         if(oElTmp.style.top!="")
  136.             nTop+=oElTmp.style.top.substring(1,oElTmp.style.top.length-2)*1;
  137.         else nTop+=oElTmp.offsetTop;
  138.         oElTmp = oElTmp.offsetParent;
  139.         }
  140.  
  141.     oElTmp=oEl;
  142.     while(oElTmp.tagName!="BODY" && oElTmp.tagName!="HTML")
  143.         {
  144.         if(oElTmp.style.left!="")
  145.             nLeft+=oElTmp.style.left.substring(1,oElTmp.style.left.length-2)*1;
  146.         else nLeft+=oElTmp.offsetLeft;
  147.         oElTmp=oElTmp.offsetParent;
  148.         }
  149.    
  150.     if(this.align=="left")
  151.         box.style.left=nLeft;
  152.     else//right
  153.         box.style.left=nLeft-143+oEl.offsetWidth;
  154.        
  155.     //box.style.top=nTop+1;//[CUSTOM]
  156.     box.style.top=nTop+1+oEl.offsetHeight;//[CUSTOM]
  157.  
  158.     this.isActive=true;
  159.    
  160.     this.refreshCustomColor();
  161.     }
  162. function hideColorPicker()
  163.     {
  164.     this.onHide();
  165.  
  166.     var box=document.getElementById("dropColor"+this.oRenderName);
  167.     box.style.display="none";
  168.     this.isActive=false;
  169.     }
  170. function hideColorPickerAll()
  171.     {
  172.     for(var i=0;i<arrColorPickerObjects.length;i++)
  173.         {
  174.         var box=document.getElementById("dropColor"+eval(arrColorPickerObjects[i]).oRenderName);
  175.         box.style.display="none";
  176.         eval(arrColorPickerObjects[i]).isActive=false;
  177.         }
  178.     }
  179.    
  180. function convertHexToDec(hex)
  181.     {
  182.     return parseInt(hex,16);
  183.     }
  184.    
  185. function convertDecToHex(dec)
  186.     {
  187.     var tmp = parseInt(dec).toString(16);
  188.     if(tmp.length == 1) tmp = ("0" +tmp);
  189.     return tmp;//.toUpperCase();
  190.     }
  191.    
  192. function convertDecToHex2(dec)
  193.     {
  194.     var tmp = parseInt(dec).toString(16);
  195.  
  196.     if(tmp.length == 1) tmp = ("00000" +tmp);
  197.     if(tmp.length == 2) tmp = ("0000" +tmp);
  198.     if(tmp.length == 3) tmp = ("000" +tmp);
  199.     if(tmp.length == 4) tmp = ("00" +tmp);
  200.     if(tmp.length == 5) tmp = ("0" +tmp);
  201.  
  202.     tmp = tmp.substr(4,1) + tmp.substr(5,1) + tmp.substr(2,1) + tmp.substr(3,1) + tmp.substr(0,1) + tmp.substr(1,1)
  203.     return tmp;//.toUpperCase();
  204.     }
  205.    
  206. //input color in format rgb(R,G,B)
  207. //ex, return by document.queryCommandValue(forcolor)
  208. function extractRGBColor(col) {
  209.     var re = /rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)/i;
  210.     if (re.test(col)) {
  211.         var result = re.exec(col);
  212.         return convertDecToHex(parseInt(result[1])) +
  213.                convertDecToHex(parseInt(result[2])) +
  214.                convertDecToHex(parseInt(result[3]));
  215.     }
  216.     return convertDecToHex2(0);
  217. }    
  218.    
downloadcolor_picker.js Source code - Download Pcook CMS bubble guest v3.0 SDCMS version Source code
Related Source Codes/Software:
Oo 126 CMS movie site system - This procedure ASP + ACC/ASP + SQL, using new kern... 2016-09-21
IDC sales web site - Beautiful IDC sales web site source code 2016-09-21
NPOINT virtual host v1.7.0 formal version management system - The system main function is introduced 2016-09-21
Classified information network business in suzhou - Overall module: classification of supply and deman... 2016-09-21
Jie Yang v0.6.3 article system - System functions: 1, the system settings A confi... 2016-09-21
Age design website information management system SDCMS v1.1 SP1 - SDCMS is designed to build the information managem... 2016-09-21
Age design website information management system SDCMS v1.1 SP1 - SDCMS is designed to build the information managem... 2016-09-21
C9 v2.1.1 static post system - Program USES ASP + ACC structure design and develo... 2016-09-21
Imitation green download station perfect version - Before increased | software home page, on the basi... 2016-09-21
Subdomain hosting edition v1.9 s taobao, pat - The background site admin 2016-09-21
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top