C_PromptBaseTimeTextBox.js 16 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_PromptBaseTimeTextBox(_c7T, _cO21, _cCB1, _cY5, _cKS){G_HAL.F_VerifyDependencies("G_ResManager");G_HAL.F_VerifyDependencies("U_PromptInputParser");G_HAL.F_VerifyDependencies("C_PromptBaseTextBox");this.F_ConstructBaseClass(_c7T, _cO21, _cCB1, _cKS);this._cVR1;this._c0D();if(typeof _cY5=="undefined"){_cY5=false;}this._cZ5=_cY5;this._cID1();this._c3Y=(this._cK81==1);if(this._c3Y){this._cVR1=new Date();this._cVR1.setMilliseconds(0);if(this._cJD1){clearInterval(this._cJD1);}this._cJD1=setInterval( "C_PromptBaseTimeTextBox._c0O( \"" + this._cOG.uniqueID + "\" )", 100 );}this._c5B={};this._c5B[ "hour" ]=null;this._c5B[ "minute" ]=null;this._c5B[ "second" ]=(this._cWX?null:true);this._c5B[ "millisecond" ]=(this._c1E?null:true);this._c5B[ "ampm" ] = ( U_PromptInputParser.F_GetProperty( U_PromptInputParser.K_e24HourClock )=="false"?null:true );this._cF1;this._cBT1();this._cE9=this._c8T;this._c431();this._cMX();};C_PromptBaseTimeTextBox.F_Extends(C_PromptBaseControl);C_PromptBaseTimeTextBox.prototype.F_Detach=function(){this._c4Y();this._c8T.F_Detach();this._c5K.F_Detach();if(this._c5Y){this._c5Y.F_Detach();}if(this._c6K){this._c6K.F_Detach();}if(this._cN7){this._cN7.F_Detach();}delete this._c5B;delete this._cVR1;this._cWO1();};C_PromptBaseTimeTextBox.prototype.F_Focus=function(){this._c8T.F_Focus();};C_PromptBaseTimeTextBox.prototype._c0D=function(){C_PromptBaseTimeTextBox.superClass._c0D.call(this);this._c9T=0;this._cWX=false;this._c1E=false;this._cK81=0;if((this._cUQ)&&this._cUQ.match(/^\d\d:\d\d:\d\d.\d\d\d$/gi)){this._cVR1=U_PromptInputParser.F_ParseTime(this._cUQ);}if(this._cWM.getAttribute("selectTimeUI")){this._c9T=( this._cWM.getAttribute( "selectTimeUI" )=="editBox" )?1:0;}if(this._cWM.getAttribute("showSeconds")){this._cWX=( this._cWM.getAttribute( "showSeconds" )=="true"?true:false );}if(this._cWM.getAttribute("showMilliseconds")){this._c1E=( this._cWM.getAttribute( "showMilliseconds" )=="true"?true:false );}if(this._cWM.getAttribute("clockMode")){this._cK81=( this._cWM.getAttribute( "clockMode" )=="live" )?1:0;}};C_PromptBaseTimeTextBox.prototype._cBT1=function(){var _cCD1=this._cOG.insertRow(0);var _cNV1=_cCD1.insertCell(0);var _c1O=false;if(this._cT5&&!this._cWC1&&!this._c0P1&&!this._cHX){this._cT3(_cNV1);_c1O=true;_cNV1=_cCD1.insertCell(1);}if(this._c9T==0){G_HAL.F_VerifyDependencies("C_PromptClockUI");_cNV1.setAttribute( "colSpan", "3" );_cNV1.setAttribute( "align", "center" );this._cHP1=new C_PromptClockUI(_cNV1, this._cVR1,(this._cWX||this._c1E), true);_cCD1=this._cOG.insertRow((this._c9T==0)?1:0);if(_c1O){_cCD1.insertCell(0);}_cNV1=_cCD1.insertCell(_cCD1.cells.length);}if(this._cT5&&!this._cUJ){if(this._cWC1){this._cRD(_cNV1);}}var _cAT=_cCD1.insertCell(_cCD1.cells.length);_cAT.style.paddingRight="5px";var _c2O=_cAT.appendChild(document.createElement("table"));_c2O.setAttribute( "border", "0" );_c2O.setAttribute( "cellPadding", "0" );_c2O.setAttribute( "cellSpacing", "0" );_c2O.style.paddingTop="2px";U_Accessibility.F_SetRoleForLayoutTable(_c2O);if(this._c1E){_c2O.className="clsCCHLSelectTimeEditBoxExtend";}else{_c2O.className="clsCCHLSelectTimeEditBox";}var _c6Y=_c2O.insertRow(0);if ((U_PromptInputParser.F_GetProperty( U_PromptInputParser.K_e24HourClock )=="false" )&&( U_PromptInputParser.F_GetProperty( U_PromptInputParser.K_eAMPMLocation )=="left" ) ){this._c5Y=this._c53( _c6Y, "ampm", "2", "2", ( ( this._cVR1.getHours() > 11 )?U_PromptInputParser.F_GetProperty( U_PromptInputParser.K_ePMString ):U_PromptInputParser.F_GetProperty( U_PromptInputParser.K_eAMString ) ), G_ResManager.F_GetString( "IDS_CCHL_AC_AM_PM" ) );this._c5Y._cF81.style["min-width"] = "25px";}this._c8T=this._c53( _c6Y, "hour", "2", "2", this._c4I1(), G_ResManager.F_GetString( "IDS_CCHL_AC_hour" ) );this._c5K=this._c53( _c6Y, "minute", "2", "2", this._cVR1.getMinutes().toString(), G_ResManager.F_GetString( "IDS_CCHL_AC_minute" ) );if(this._cWX||this._c1E){this._c6K=this._c53( _c6Y, "second", "2", "2", this._cVR1.getSeconds().toString(), G_ResManager.F_GetString( "IDS_CCHL_AC_second" ) );}if(this._c1E){this._cN7=this._c53( _c6Y, "millisecond", "3", "3", this._cVR1.getMilliseconds().toString(), G_ResManager.F_GetString( "IDS_CCHL_AC_millisecond" ) );}if ((U_PromptInputParser.F_GetProperty( U_PromptInputParser.K_e24HourClock )=="false" )&&( U_PromptInputParser.F_GetProperty( U_PromptInputParser.K_eAMPMLocation )=="right" ) ){this._c5Y=this._c53( _c6Y, "ampm", "2", "2", ( ( this._cVR1.getHours() > 11 )?U_PromptInputParser.F_GetProperty( U_PromptInputParser.K_ePMString ):U_PromptInputParser.F_GetProperty( U_PromptInputParser.K_eAMString ) ), G_ResManager.F_GetString( "IDS_CCHL_AC_AM_PM" ) );this._c5Y._cF81.style["min-width"] = "25px";}this._cF1="";var _c2I1=_c6Y.insertCell(_c6Y.cells.length);_c2I1.style.width="100%";_c2I1.innerHTML="&nbsp;";var _c3O=_cCD1.insertCell(_cCD1.cells.length);this._c0H(_c3O);};C_PromptBaseTimeTextBox.prototype._c4I1=function(){var _cWR1=this._cVR1.getHours();if((_cWR1>11)&&(U_PromptInputParser.F_GetProperty(U_PromptInputParser.K_e24HourClock)=="false")){_cWR1=_cWR1-12;}if((_cWR1==0)&&(U_PromptInputParser.F_GetProperty(U_PromptInputParser.K_e24HourClock)=="false")){_cWR1=12;}return _cWR1.toString();};C_PromptBaseTimeTextBox.prototype._c53=function(_cMV1,_c4O,_cXR1,_cL81,_cKS,_cC81){if ((_c4O=="minute" )||( _c4O=="second" ) ){this._c36(_cMV1, U_PromptInputParser.F_GetProperty(U_PromptInputParser.K_eTimeSeparator));}if(_c4O=="millisecond"){this._c36(_cMV1, ".");}var _c6M=this._cD2(_c4O);this._cF1=_c4O;_c6M.setAttribute("validation", _c4O);_c6M.setAttribute("formatting", _c4O);var _cNV1=_cMV1.insertCell(_cMV1.cells.length);_cNV1.style.verticalAlign="bottom";var _cVG=_cNV1.appendChild(document.createElement("table"));U_Accessibility.F_SetRoleForLayoutTable(_cVG);this._cF7(_cVG, "tbl_"+_c4O);_c6M.setAttribute("size", _cXR1);_c6M.setAttribute("maxlength", _cL81);_c6M.setAttribute( "required", "true" );C_PromptControl.F_AddAriaLabelParm(_c6M, _cC81);return new C_PromptBaseTextBox(_cVG, _c6M, this, _cKS);};C_PromptBaseTimeTextBox.prototype._c36=function(_cMV1,_cM81){var _cNV1=_cMV1.insertCell(_cMV1.cells.length);_cNV1.className="clsCCHLColon";_cNV1.style.paddingBottom="3px";_cNV1.innerHTML=_cM81;};C_PromptBaseTimeTextBox.prototype._c0H=function(_c3O){var _c7K=_c3O.appendChild(document.createElement("table"));_c7K.setAttribute( "border", "0" );_c7K.setAttribute( "cellPadding", "0" );_c7K.setAttribute( "cellSpacing", "0" );U_Accessibility.F_SetRoleForLayoutTable(_c7K);var _c8K=_c7K.insertRow(0);var _c9K=_c8K.insertCell(0);this._cF9(_c9K, true);var _c8E=_c7K.insertRow(1);var _c9E=_c8E.insertCell(0);this._cF9(_c9E, false);};C_PromptBaseTimeTextBox.prototype._cF9=function(_cAT,_c7V1){_cAT.className="clsCCHLToolbarButton";_cAT.onmouseover=C_PromptBaseTimeTextBox._cAK;_cAT.onmouseout=C_PromptBaseTimeTextBox._cAK;var _cSH1=(_c7V1?"_cBK":"_cAE");this._cPG(_cAT, "mousedown", this[_cSH1].bind(this));var _c5O=_cAT.appendChild(document.createElement("img"));_c5O.style.width="15px";_c5O.style.height="7px";_c5O.setAttribute( "border", "0" );_c5O.src=G_HAL.F_GetImageURL( "cchl/images/icon_time_" + ( _c7V1?"up":"down" ) + ".gif" );if(G_HAL.M_oLibraries["hal"]["enableAccessibility"]){_c5O.tabIndex=0;_c5O.setAttribute("role", "button");_c5O.alt=_c7V1?G_ResManager.F_GetString("IDS_CCHL_AC_TIME_INCREAS"):G_ResManager.F_GetString("IDS_CCHL_AC_TIME_DECREAS");this._cPG(_c5O, "keydown", this[_cSH1].bind(this));}};C_PromptBaseTimeTextBox.prototype._cD2=function(_c4O){var _c2P1=U_XML.F_CreateDocument();var _c6M=_c2P1.createElement("promptTextBox");_c6M.setAttribute( "required", ( this._cWC1?"true":"false" ) );_c6M.setAttribute( "multiSelect", (!this._cHX?"false":"true") );_c6M.setAttribute( "hideAdornments", ( this._cUJ?"true":"false" ) );_c6M.setAttribute( "renderAdornmentsCell", "false" );_c6M.setAttribute( "inputClass", "clsCCHLSelectTimeControl" );_c6M.setAttribute( "inputSelectMode", "true" );if(this._cKN&&(_c4O!="ampm")){_c6M.setAttribute( "restrictInput", "true" );_c6M.setAttribute( "restrictInputExponents", "true" );_c6M.setAttribute( "restrictInputNegatives", "true" );}return _c6M;};C_PromptBaseTimeTextBox._cAK=function(e){e.stopPropagation();if(this.className=="clsCCHLToolbarButton"){this.className="clsCCHLToolbarButton_hover";}else{this.className="clsCCHLToolbarButton";}};C_PromptBaseTimeTextBox.prototype._cBK=function(e){e.stopPropagation();if(e.type==="keydown"&&(e.keyCode!==U_DOM.K_iKeyEnter /*&& e.keyCode!==U_DOM.K_iKeySpace*/)){return true;}this._cKD1(true);};C_PromptBaseTimeTextBox.prototype._cAE=function(e){e.stopPropagation();if(e.type==="keydown"&&(e.keyCode!==U_DOM.K_iKeyEnter /*&& e.keyCode!==U_DOM.K_iKeySpace*/)){return true;}this._cKD1(false);};C_PromptBaseTimeTextBox.prototype._cKD1=function(_cN81){this._c4Y();var _c8R1=new Date(this._cVR1.toString());_c8R1.setMilliseconds(this._cVR1.getMilliseconds());switch(this._cE9){case this._c5K:_c8R1.setMinutes(_c8R1.getMinutes()+(_cN81?1:-1));this._cVR1.setMinutes(_c8R1.getMinutes());this._c6O(true);break;case this._c6K:_c8R1.setSeconds(_c8R1.getSeconds()+(_cN81?1:-1));this._cVR1.setSeconds(_c8R1.getSeconds());this._c7O(true);break;case this._cN7:_c8R1.setMilliseconds(_c8R1.getMilliseconds()+(_cN81?1:-1));this._cVR1.setMilliseconds(_c8R1.getMilliseconds());this._cG9(true);break;case this._c5Y:_c8R1.setHours(_c8R1.getHours()+12);this._cVR1.setHours(_c8R1.getHours());this._c531(true);break;case this._c8T:default:_c8R1.setHours(_c8R1.getHours()+(_cN81?1:-1));this._cVR1.setHours(_c8R1.getHours());this._c7Y(true);break;}this._c431();if(!this._cHX){this._cU3();}};C_PromptBaseTimeTextBox.prototype.F_PromptControl_OnFocus=function(_c5M){this._cE9=_c5M;this._cG21();};C_PromptBaseTimeTextBox.prototype._cID1=function(){this._cVR1=new Date();if(this._cZ5){this._cVR1.setHours(23);this._cVR1.setMinutes(59);this._cVR1.setSeconds(59);this._cVR1.setMilliseconds(999);}else{this._cVR1.setHours(0);this._cVR1.setMinutes(0);this._cVR1.setSeconds(0);this._cVR1.setMilliseconds(0);}this._c431();};C_PromptBaseTimeTextBox.prototype._c4Y=function(){if(this._c3Y){this._c3Y=false;clearInterval(this._cJD1);}};C_PromptBaseTimeTextBox.prototype.F_PromptControl_OnValidUserInput=function(_cTN){var _c6B=this._c1K();this._c16(_cTN, true);if(!_c6B&&this._c1K()){this._cE7(true);this._cK7();}};C_PromptBaseTimeTextBox.prototype.F_PromptControl_OnInvalidUserInput=function(_cTN){var _c6B=this._c1K();this._c16(_cTN, false);if(_c6B&&!this._c1K()){this._cE7(false);this._cU4();}};C_PromptBaseTimeTextBox.prototype._c16=function(_cTN,_cDP1){switch(_cTN){case this._c8T:this._c5B[ "hour" ]=_cDP1;break;case this._c5K:this._c5B[ "minute" ]=_cDP1;break;case this._c6K:this._c5B[ "second" ]=_cDP1;break;case this._cN7:this._c5B[ "millisecond" ]=_cDP1;break;case this._c5Y:this._c5B[ "ampm" ]=_cDP1;break;default:this._c5B[ this._cF1 ]=_cDP1;}};C_PromptBaseTimeTextBox.prototype._c1K=function(){if(this._c5B[ "hour" ]&& this._c5B[ "minute" ]&& this._c5B[ "second" ]&& this._c5B[ "millisecond" ]&& this._c5B[ "ampm" ]){return true;}else{return false;}};C_PromptBaseTimeTextBox.prototype.F_GetParameterValue=function(){var _c6R1;if(this._cF21&&!this._cF21.checked){_c6R1=null;}else{var _cIP1=this._cVR1.getHours().toString();if(_cIP1.length==1){_cIP1="0"+_cIP1;}var _c5I1=this._cVR1.getMinutes().toString();if(_c5I1.length==1){_c5I1="0"+_c5I1;}var _c6I1=this._cVR1.getSeconds().toString();if(_c6I1.length==1){_c6I1="0"+_c6I1;}var _cBT=this._cVR1.getMilliseconds().toString();if(_cBT.length==2){_cBT="0"+_cBT;}else if(_cBT.length==1){_cBT="00"+_cBT;}var _c6R1=( this._cQD?"'":"" ) + _cIP1 + ":" + _c5I1 + ":" + _c6I1 + "." + _cBT + ( this._cQD?"'":"" );}return(new C_TimeValue(false, _c6R1, this._cWX, this._c1E));};C_PromptBaseTimeTextBox._c0O=function(_cLD1){var _cNG=document.getElementById(_cLD1);var _c5M=_cNG._cJN;_c5M._cVR1=new Date();_c5M._cVR1.setMilliseconds(0);_c5M._cCK();};C_PromptBaseTimeTextBox.prototype._cCK=function(){this._c7Y(false);this._c6O(false);this._c7O(false);this._c431();};C_PromptBaseTimeTextBox.prototype._c7Y=function(_cZL1){this._c531(false);this._c8T.F_SetValue(this._c4I1(), null, _cZL1);};C_PromptBaseTimeTextBox.prototype._c6O=function(_cZL1){this._c5K.F_SetValue(this._cVR1.getMinutes().toString(), null, _cZL1);};C_PromptBaseTimeTextBox.prototype._c7O=function(_cZL1){if(this._c6K){this._c6K.F_SetValue(this._cVR1.getSeconds().toString(), null, _cZL1);}};C_PromptBaseTimeTextBox.prototype._cG9=function(_cZL1){if(this._cN7){this._cN7.F_SetValue(this._cVR1.getMilliseconds().toString(), null, _cZL1);}};C_PromptBaseTimeTextBox.prototype._c531=function(_cZL1){if(this._c5Y){if(this._cVR1.getHours()>11){this._c5Y.F_SetValue(U_PromptInputParser.F_GetProperty(U_PromptInputParser.K_ePMString), null, _cZL1);}else{this._c5Y.F_SetValue(U_PromptInputParser.F_GetProperty(U_PromptInputParser.K_eAMString), null, _cZL1);}}};C_PromptBaseTimeTextBox.prototype.F_PromptTextBox_OnValueChange=function(_cTN){this._c4Y();if(!_cTN.F_ValidateInput()){return;}switch(_cTN){case this._c8T:var _c7I1=0;var _cJP1=parseInt(_cTN.F_GetDisplayValue(), 10);if((this._c5Y)&&(this._c5Y.F_GetDisplayValue()==U_PromptInputParser.F_GetProperty(U_PromptInputParser.K_ePMString))&&(_cJP1<12)){_c7I1=12;}else if((this._c5Y)&&(this._c5Y.F_GetDisplayValue()==U_PromptInputParser.F_GetProperty(U_PromptInputParser.K_eAMString))&&(_cJP1==12)){_c7I1=-12;}this._cVR1.setHours(_cJP1+_c7I1);break;case this._c5K:this._cVR1.setMinutes(parseInt(_cTN.F_GetDisplayValue(), 10));break;case this._c6K:this._cVR1.setSeconds(parseInt(_cTN.F_GetDisplayValue(), 10));break;case this._cN7:this._cVR1.setMilliseconds(parseInt(_cTN.F_GetDisplayValue(), 10));break;}this._c431();};C_PromptBaseTimeTextBox.prototype.F_PromptTextBox_OnBlur=function(_cTN){if(_cTN.F_ValidateInput()){switch(_cTN){case this._c5Y:var _cYR1=_cTN.F_GetDisplayValue();var _cJP1=this._cVR1.getHours();if((_cYR1==U_PromptInputParser.F_GetProperty(U_PromptInputParser.K_eAMString))&&(_cJP1>11)){this._cVR1.setHours(_cJP1-12);}else if((_cYR1==U_PromptInputParser.F_GetProperty(U_PromptInputParser.K_ePMString))&&(_cJP1<12)){this._cVR1.setHours(_cJP1+12);}break;case this._c8T:if(U_PromptInputParser.F_GetProperty(U_PromptInputParser.K_e24HourClock)=="false"){if(this._cVR1.getHours()>11){this._c5Y.F_SetValue(U_PromptInputParser.F_GetProperty(U_PromptInputParser.K_ePMString));}_cTN.F_SetValue(this._c4I1());}break;}}else{switch(_cTN){case this._c8T:_cTN.F_SetValue(this._c4I1());break;case this._c5K:_cTN.F_SetValue(this._cVR1.getMinutes().toString());break;case this._c6K:_cTN.F_SetValue(this._cVR1.getSeconds().toString());break;case this._cN7:_cTN.F_SetValue(this._cVR1.getMilliseconds().toString());break;case this._c5Y:if(this._cVR1.getHours()<12){_cTN.F_SetValue(U_PromptInputParser.F_GetProperty(U_PromptInputParser.K_eAMString));}else{_cTN.F_SetValue(U_PromptInputParser.F_GetProperty(U_PromptInputParser.K_ePMString));}break;}}this._c431();};C_PromptBaseTimeTextBox.prototype._c431=function(){if(this._cHP1){this._cHP1.F_UpdateClock(this._cVR1);}};C_PromptBaseTimeTextBox.prototype.F_SetEnabled=function(_cQL1){if(this._c8T){this._c8T.F_SetEnabled(_cQL1);}if(this._c5K){this._c5K.F_SetEnabled(_cQL1);}if(this._c6K){this._c6K.F_SetEnabled(_cQL1);}if(this._cN7){this._cN7.F_SetEnabled(_cQL1);}if(this._c5Y){this._c5Y.F_SetEnabled(_cQL1);}};C_PromptBaseTimeTextBox.prototype.F_ClearParameterValue=function(){this._cID1();this._c7Y(false);this._c6O(false);this._c7O(false);this._cG9(false);};C_PromptBaseTimeTextBox.prototype.F_SetParameterValue=function(_cYO1){var _cWB1=this.F_ToUseValue(_cYO1);if(!_cWB1||!_cWB1.match(/^\d{1,2}:\d{1,2}:\d{1,2}.\d{1,3}$/g)){this.F_ClearParameterValue();}else{var _cRL1=_cWB1.split(/[:,.]+/i);this._cVR1.setHours(+_cRL1[0]);this._cVR1.setMinutes(+_cRL1[1]);this._cVR1.setSeconds(+_cRL1[2]);this._cVR1.setMilliseconds(+_cRL1[3]);this._c431();this._c7Y(false);this._c6O(false);this._c7O(false);this._cG9(false);}};C_PromptBaseTimeTextBox.prototype.F_SetValidator=function(_cN21){this._c8T.F_SetValidator(_cN21);this._c5K.F_SetValidator(_cN21);if(this._c5Y){this._c5Y.F_SetValidator(_cN21);}if(this._c6K){this._c6K.F_SetValidator(_cN21);}if(this._cN7){this._cN7.F_SetValidator(_cN21);}};