C_ColorPicker.js 11 KB

123456
  1. // Licensed Materials - Property of IBM
  2. // IBM Cognos Products: cchl
  3. // (C) Copyright IBM Corp. 2003, 2016.
  4. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  5. function C_ColorPicker(_cYF1, _cYI, _cCB1){this._cYK1=0;this._cKM=1;this._cLM=1;this._c3H1="";this._c4H1=_cYF1;this._cDB1=_cCB1;this._cBQ="";this._cZI=_cYI;this._cAT1();};C_ColorPicker._cBW=150;C_ColorPicker._cOC=11;C_ColorPicker._cHR=150;C_ColorPicker._cH8=6;C_ColorPicker.prototype._cCW=function(_cZK1){return this._cZI+_cZK1;};C_ColorPicker.prototype._cAT1=function(){this._c4H1.innerHTML=this._c0J();G_ResManager.F_ApplyResStrings(this._c4H1);this._cP61=document.getElementById(this._cCW("divPreview"));this._cQ61=document.getElementById(this._cCW("divPalette"));this._cV6=document.getElementById(this._cCW("divSelectorInPalette"));this._cUB1=document.getElementById(this._cCW("divHueBar"));this._cPC=document.getElementById(this._cCW("divSliderInHueBar"));this._c4O1=document.getElementById(this._cCW("txtRed"));this._c5O1=document.getElementById(this._cCW("txtHue"));this._c5H1=document.getElementById(this._cCW("txtGreen"));this._c6O1=document.getElementById(this._cCW("txtSat"));this._c0L1=document.getElementById(this._cCW("txtBlue"));this._c7O1=document.getElementById(this._cCW("txtBri"));this._cR61=document.getElementById(this._cCW("txtRgbCode"));this._c4O1.onkeypress=U_DOM.F_NumbersOnlyOnKeyPressHandler;this._c5H1.onkeypress=U_DOM.F_NumbersOnlyOnKeyPressHandler;this._c0L1.onkeypress=U_DOM.F_NumbersOnlyOnKeyPressHandler;this._c5O1.onkeypress=U_DOM.F_NumbersOnlyOnKeyPressHandler;this._c6O1.onkeypress=U_DOM.F_NumbersOnlyOnKeyPressHandler;this._c7O1.onkeypress=U_DOM.F_NumbersOnlyOnKeyPressHandler;this._cF5();this._cV6.style.top=-(C_ColorPicker._cOC/2)+'px';this._cV6.style.left=(C_ColorPicker._cBW-C_ColorPicker._cOC/2)+'px';};C_ColorPicker.prototype.F_Detach=function(){this._c4H1=null;this._cDB1=null;this._cP61=null;this._cQ61=null;this._cV6=null;this._cUB1=null;this._cPC=null;this._c4O1=null;this._c5O1=null;this._c5H1=null;this._c6O1=null;this._c0L1=null;this._c7O1=null;this._cR61=null;};C_ColorPicker.prototype.F_UpdateViewFromExistingValue=function(_cHN1,_cAQ){if(_cHN1&&_cHN1.substr(1).match(/^[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]$/i)){_cHN1=_cHN1.substr(1);this._cR61.value=_cHN1;var _cGT1=U_Color.F_ConvertRgbCodeToHSV(_cHN1);this._cYK1=_cGT1.hue;this._cKM=_cGT1.saturation;this._cLM=_cGT1.brightness;if(_cAQ){this._cBQ=_cAQ;}this._cS61();}};C_ColorPicker.prototype.F_ClearAll=function(){this._c3H1="";this._cYK1=0;this._c4O1.value="";this._c5H1.value="";this._c0L1.value="";this._c5O1.value="";this._c6O1.value="";this._c7O1.value="";this._cR61.value="";this._cQ61.style.backgroundColor="";this._cV6.style.top=-(C_ColorPicker._cOC/2)+'px';this._cV6.style.left=(C_ColorPicker._cBW-C_ColorPicker._cOC/2)+'px';this._cPC.style.top=(C_ColorPicker._cHR-C_ColorPicker._cH8 / 2)+'px';this._cP61.style.backgroundColor="";};C_ColorPicker.prototype.F_GetCustomColor=function(){if(this._c4O1.value+this._c5H1.value+this._c0L1.value){return "#"+this._c3H1;}return "";};C_ColorPicker.prototype._cF5=function(){this._cV6.onmousedown=this._c1J.bind(this);this._cQ61.onmousedown=this._c1J.bind(this);this._cPC.onmousedown=this._cL11.bind(this);this._cUB1.onmousedown=this._cL11.bind(this);this._c4O1.onchange=this._cYF.bind(this);this._c5H1.onchange=this._cYF.bind(this);this._c0L1.onchange=this._cYF.bind(this);this._c5O1.onchange=this._cZF.bind(this);this._c6O1.onchange=this._cZF.bind(this);this._c7O1.onchange=this._cZF.bind(this);this._cR61.onchange=this._cW6.bind(this);};C_ColorPicker.prototype._c2J=function(){if(this._cDB1&&this._cDB1.F_ColorPicker_OnColorChange){this._cDB1.F_ColorPicker_OnColorChange("#"+this._c3H1);}};C_ColorPicker.prototype._cM11=function(){this._c3H1=U_Color.F_ConvertHsvToRgbCode(this._cYK1, this._cKM, this._cLM);this._cR61.value=this._c3H1;if(!this._c3H1){this._c4O1.value="";this._c5H1.value="";this._c0L1.value="";}else{this._c4O1.value=parseInt(this._c3H1.substr(0, 2), 16);this._c5H1.value=parseInt(this._c3H1.substr(2, 2), 16);this._c0L1.value=parseInt(this._c3H1.substr(4, 2), 16);}this._c2J();};C_ColorPicker.prototype._cN11=function(){this._c3H1=U_Color.F_ConvertHsvToRgbCode(this._cYK1, this._cKM, this._cLM);this._cR61.value=this._c3H1;this._c5O1.value=Math.round(this._cYK1);this._c6O1.value=Math.round(this._cKM*100);this._c7O1.value=Math.round(this._cLM*100);this._c2J();};C_ColorPicker.prototype._cS61=function(callback){G_Debug.F_Print("C_ColorPicker.prototype._cS61");this._cQC();this._cRC();this._cI8();if(callback&&typeof callback==="function"){callback.apply(this);this._cSC();return;}this._cM11();this._cN11();this._cSC();};C_ColorPicker.prototype._cQC=function(){this._cQ61.style.backgroundColor='#'+U_Color.F_ConvertHsvToRgbCode(this._cYK1, 1, 1);};C_ColorPicker.prototype._cSC=function(){if(this._c3H1&&this._cP61){this._cP61.style.backgroundColor='#'+this._c3H1;}if(this._cBQ){U_DOM.F_SetOpacity(this._cP61,(100-parseInt(this._cBQ)).toString());}};C_ColorPicker.prototype._cRC=function(){var _c1L1=C_ColorPicker._cBW-Math.round(((this._cYK1 / 360)*C_ColorPicker._cBW));this._cPC.style.top=(_c1L1-C_ColorPicker._cH8 / 2)+'px';};C_ColorPicker.prototype._cI8=function(){var _c6H1=Math.round(this._cKM*(C_ColorPicker._cBW))-C_ColorPicker._cOC/2;var _c1L1=C_ColorPicker._cBW-Math.round(this._cLM*C_ColorPicker._cBW)-C_ColorPicker._cOC/2;this._cV6.style.left=(_c6H1?_c6H1:-C_ColorPicker._cOC/2)+'px';this._cV6.style.top=(_c1L1?_c1L1:(C_ColorPicker._cBW-C_ColorPicker._cOC/2))+'px';};C_ColorPicker.prototype._cL11=function(e){G_CaptureManager.F_StartCapture({onmousemove:this._cDW.bind(this),onmouseup: this._cT61.bind(this)});this._cDW(e);};C_ColorPicker.prototype._c1J=function(e){G_CaptureManager.F_StartCapture({onmousemove:this._cIR.bind(this),onmouseup: this._cMM.bind(this)});this._cIR(e);};C_ColorPicker.prototype._cDW=function(e){this._c7H1=U_DOM.F_GetRelativeOffset(this._cUB1, this._cUB1.ownerDocument.body).top;if(this._c7H1>0){var _c4R1=e.clientY-this._c7H1;_c4R1=Math.min(_c4R1, C_ColorPicker._cBW);_c4R1=Math.max(_c4R1, 0);this._cPC.style.top=(_c4R1-C_ColorPicker._cH8 / 2)+'px';var _cHT1=Math.round(((C_ColorPicker._cBW-_c4R1)*(360 / C_ColorPicker._cBW)));this._cYK1=_cHT1;this._cQC();this._cM11();this._cN11();this._cSC();}};C_ColorPicker.prototype._cIR=function(e){var _c2L1=U_DOM.F_GetRelativeOffset(this._cQ61, this._cQ61.ownerDocument.body).left;var _c8O1=U_DOM.F_GetRelativeOffset(this._cQ61, this._cQ61.ownerDocument.body).top;var _cU61=e.clientX-_c2L1;var _cVB1=e.clientY-_c8O1;_cU61=Math.max(_cU61, 0);_cU61=Math.min(_cU61, C_ColorPicker._cBW);_cVB1=Math.max(_cVB1, 0);_cVB1=Math.min(_cVB1, C_ColorPicker._cBW);this._cV6.style.left=(_cU61-C_ColorPicker._cOC/2)+'px';this._cV6.style.top=(_cVB1-C_ColorPicker._cOC/2)+'px';this._cKM=_cU61 / C_ColorPicker._cBW;this._cLM=1-(_cVB1 / C_ColorPicker._cBW);this._cM11();this._cN11();this._cSC();};C_ColorPicker.prototype._cMM=function(){G_CaptureManager.F_StopCapture();};C_ColorPicker.prototype._cT61=function(){G_CaptureManager.F_StopCapture();};C_ColorPicker.prototype._cX6=function(){var _cHN1=U_Color.F_ConvertRgbColorToRgbCode(this._c4O1.value, this._c5H1.value, this._c0L1.value);var _cGT1=U_Color.F_ConvertRgbCodeToHSV(_cHN1);this._cYK1=_cGT1.hue;this._cKM=_cGT1.saturation;this._cLM=_cGT1.brightness;this._cS61(this._cN11);};C_ColorPicker.prototype._cY6=function(){this._cYK1=parseInt(this._c5O1.value);this._cKM=this._c6O1.value / 100;this._cLM=this._c7O1.value / 100;this._cS61(this._cM11);};C_ColorPicker.prototype._cYF=function(e){var _cIT1=e.target;var _cGN1=_cIT1.value;if(!_cGN1.match(/^[0-9]+$/i)){_cGN1=0;}_cGN1=Math.min(_cGN1, 255);_cIT1.value=_cGN1;if(this._c4O1.value&&this._c5H1.value&&this._c0L1.value){this._cX6();}};C_ColorPicker.prototype._cZF=function(e){var _cIT1=e.target;var _cGN1=_cIT1.value;if(!_cGN1.match(/^[0-9]+$/i)){_cGN1=0;}if(_cIT1.id==this._cCW("txtHue")){_cGN1=Math.min(_cGN1 , 360);}else{_cGN1=Math.min(_cGN1 , 100);}_cIT1.value=_cGN1;if(this._c5O1.value&&this._c6O1.value&&this._c7O1.value){this._cY6();}};C_ColorPicker.prototype._cW6=function(e){var _cIT1=e.target;var _c8H1=_cIT1.value;if(!_c8H1.match(/^[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]$/i)){_c8H1='';_cIT1.value='';}else{var _cGT1=U_Color.F_ConvertRgbCodeToHSV(_c8H1);this._cYK1=_cGT1.hue;this._cKM=_cGT1.saturation;this._cLM=_cGT1.brightness;this._cS61();}};C_ColorPicker.prototype._c0J=function(){return('<div class="clsLabelSequence">'+G_ResManager.F_GetString("IDS_CCHL_LBL_PREVIEW2")+'</div>' +'<div class="clsContainerBorder"><div id=' + this._cCW("divPreview") + ' class="clsPreviewDiv"></div></div>' + '<div style="float: left; margin-top: 20px; margin-right: 20px;" id=' + this._cCW("divPalette") + ' class="clsPalette">' + '<div id=' + this._cCW("divSelectorInPalette") + ' style="float: left;" class="clsPaletteIndicator"></div>' + '</div>'+'<div style="float: left; margin-right: 0px; margin-top: 20px;" id=' + this._cCW("divHueBar") + ' class="clsHueBar"></div>' + '<div id=' + this._cCW("divSliderInHueBar") + ' style="float: left; margin-top: 18px;" class="clsSliderInHueBar"></div>' + '<div style="float: left; margin-top: 0px;">' + '<table role="presentation" class="clsDialogText" cellpadding="0" cellspacing="0">' + '<tr>'+'<td class="clsLabelSequence" HAL_ids="IDS_CCHL_LBL_R"></td>' + '<td style="width:20px;"></td>' + '<td class="clsLabelSequence" HAL_ids="IDS_CCHL_LBL_HUE"><td>' + '<td></td>'+'</tr>'+'<tr>'+'<td><input type="text" HAL_idsAriaLabel="IDS_CCHL_LBL_R" class="clsTextBox clsCCHLNumeric" maxlength="3" id=' + this._cCW("txtRed") + ' style="width: 50px;" onkeydown="event.stopPropagation()"/></td>' + '<td style="width:20px;"></td>' + '<td><input type="text" HAL_idsAriaLabel="IDS_CCHL_LBL_HUE" class="clsTextBox clsCCHLNumeric" maxlength="3" id=' + this._cCW("txtHue") + ' style="width: 50px;" onkeydown="event.stopPropagation()"/></td>' + '<td></td>'+'</tr>'+'<tr>'+'<td class="clsLabelSequence" HAL_ids="IDS_CCHL_LBL_G"></td>' + '<td style="width:20px;"></td>' + '<td class="clsLabelSequence" HAL_ids="IDS_CCHL_LBL_SATURATION"></td>' + '<td></td>'+'</tr>'+'<tr>'+'<td><input type="text" HAL_idsAriaLabel="IDS_CCHL_LBL_G" class="clsTextBox clsCCHLNumeric" maxlength="3" id=' + this._cCW("txtGreen") + ' style="width: 50px;" onkeydown="event.stopPropagation()"/></td>' + '<td style="width:20px;"></td>' + '<td><input type="text" HAL_idsAriaLabel="IDS_CCHL_LBL_SATURATION" class="clsTextBox clsCCHLNumeric" maxlength="3" id=' + this._cCW("txtSat") + ' style="width: 50px;" onkeydown="event.stopPropagation()"/></td>' + '<td></td>'+'</tr>'+'<tr>'+'<td class="clsLabelSequence" HAL_ids="IDS_CCHL_LBL_B"></td>' + '<td style="width:20px;"></td>' + '<td class="clsLabelSequence" HAL_ids="IDS_CCHL_LBL_BRIGHTNESS"></td>' + '<td></td>'+'</tr>'+'<tr>'+'<td><input type="text" HAL_idsAriaLabel="IDS_CCHL_LBL_B" class="clsTextBox clsCCHLNumeric" maxlength="3" id=' + this._cCW("txtBlue") + ' style="width: 50px;" onkeydown="event.stopPropagation()"/></td>' + '<td style="width:20px;"></td>' + '<td><input type="text" HAL_idsAriaLabel="IDS_CCHL_LBL_BRIGHTNESS" class="clsTextBox clsCCHLNumeric" maxlength="3" id=' + this._cCW("txtBri") + ' style="width: 50px;" onkeydown="event.stopPropagation()"/></td>' + '<td></td>'+'</tr>'+'<tr>'+'<td class="clsLabelSequence" HAL_ids="IDS_CCHL_LBL_RGBCODE"></td>' +'<td></td>'+'<td></td>'+'<td></td>'+'</tr>'+'<tr>'+'<td><input type="text" HAL_idsAriaLabel="IDS_CCHL_LBL_RGBCODE" class="clsTextBox" maxlength="6" id=' + this._cCW("txtRgbCode") + ' style="width: 50px;" onkeydown="event.stopPropagation()"/></td>' + '<td></td>'+'<td></td>'+'<td></td>'+'</tr>'+'</table>'+'</div>'+'</div>');};