123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693 |
- function CDatePicker(oSubmit, oForm, oEditBox, oDialog, sRef, sDefaultDate, iInline, iType, sInputOrder, iStartOfWeek, iDateTimeType, sFirstDate, sLastDate, bRequired, sSubmitType, oImgCheck, sCVId, popupZIndex)
- {
- this.setCVId(sCVId);
- this.m_oSubmit = oSubmit;
- this.m_oForm = oForm;
- this.m_oEditBox = oEditBox;
- this.m_oDialog = oDialog;
- this.m_sRef = sRef;
- this.m_popupZIndex = popupZIndex;
-
- this.m_sInputOrder = g_dateOrder;
-
- if (sDefaultDate)
- {
-
- var sTestDate = sDefaultDate.split("T");
-
- this.m_dDate = dParseDate(sTestDate[0], "YMD");
- if ((this.m_dDate === false) || (!this.m_dDate))
- {
- this.m_dDate = new Date();
- }
- }
- else
- {
- this.m_dDate = new Date();
- }
-
-
-
- this.m_iInline = iInline;
-
- this.m_iStartOfWeek = g_startDayOfWeek;
-
- this.m_iType = iType;
-
-
-
- this.m_iDateTimeType = iDateTimeType;
-
- if (sFirstDate)
- {
- this.m_dFirstDate = dParseDate(sFirstDate,"YMD");
- if (this.m_dFirstDate > this.m_dDate)
- {
-
-
- this.m_dDate = this.m_dFirstDate;
- }
- }
-
- if (sLastDate)
- {
- this.m_dLastDate = dParseDate(sLastDate,"YMD");
- if (this.m_dLastDate < this.m_dDate)
- {
-
-
- this.m_dDate = this.m_dLastDate;
- }
- }
-
- this.m_bRequired = bRequired;
- this.m_bDisabled = false;
-
- this.m_bValid = false;
-
- this.m_sSubmitType = sSubmitType;
-
- this.m_isNS7 = browserIsNS7();
-
- this.m_sSkin = (typeof getPromptSkin != K_PRMT_sUNDEFINED ? getPromptSkin() : K_PRMT_sDEFAULTSKIN);
-
- this.m_oImgCheckDate = oImgCheck;
- if (!this.m_oImgCheckDate)
- {
- this.m_oImgCheckDate = document.getElementById('imgTest'+sRef);
- }
- if (this.m_oImgCheckDate)
- {
- this.m_oImgErrorFalse= new Image();
- this.m_oImgErrorFalse.src = this.m_sSkin + "/prompting/images/error_timed_small_off.gif";
- this.m_oImgErrorTrue = new Image();
- this.m_oImgErrorTrue.src = this.m_sSkin + "/prompting/images/error_timed_small.gif";
- }
- this.updateFormVariable(this.m_oForm, this.m_dDate);
- this.drawDate();
-
- this.checkDate(this.m_oEditBox);
- if ( iInline === 0 )
- {
- this.m_bIsBux = this.f_isBUX();
- }
-
- this.m_oDatePickerDialog = new CDatePickerDialog(this.m_oDialog, this, sRef, iInline, iType, this.m_iStartOfWeek, sCVId, this.m_popupZIndex);
- this.m_oDatePickerDialog.m_bIsBux = this.m_bIsBux;
- }
- CDatePicker.prototype = new CPromptControl();
- function CDatePicker_updateFormVariable(oForm, dNewDate)
- {
-
- if (dNewDate)
- {
-
-
-
- var sNewYear = dNewDate.getFullYear();
-
- sNewYear = "0000" + sNewYear;
- sNewYear = sNewYear.substring(sNewYear.length-4, sNewYear.length);
- var sNewMonth = (parseInt(dNewDate.getMonth(), 10) + 1).toString();
-
- if (sNewMonth.length == 1)
- {
- sNewMonth = "0" + sNewMonth;
- }
- var sNewDay = (dNewDate.getDate()).toString();
-
- if (sNewDay.length == 1)
- {
- sNewDay = "0" + sNewDay;
- }
- var sNewValue = sNewYear + "-" + sNewMonth + "-" + sNewDay;
-
-
- if (this.m_iDateTimeType === 0)
- {
- sNewValue += "T00:00:00.000";
- }
-
- this.m_oForm.value = sNewValue;
- }
- else
- {
-
- this.m_oForm.value = K_PRMT_sEMPTY;
- }
- this.notify(gUPDATE, this);
- }
- function CDatePicker_drawDate()
- {
- var sFormatDate = K_PRMT_sEMPTY;
- if (this.m_dDate)
- {
-
- sFormatDate = getFormatDate (this.m_dDate, this.m_iType, this.m_sInputOrder);
- }
- if (this.m_iInline === 0)
- {
- this.m_oEditBox.value = sFormatDate;
- }
- }
- function CDatePicker_toggleDialogDatePicker(oObj)
- {
-
- if (this.m_dDate)
- {
- this.m_oDatePickerDialog.refreshDate(this.m_dDate);
- }
- else
- {
-
- var dToday = new Date();
- this.m_dDate = dToday;
-
- this.updateFormVariable(this.m_oForm, this.m_dDate);
-
- this.drawDate();
- this.m_oDatePickerDialog.refreshDate(dToday);
- }
- if ( !oObj.m_bSetOnBody )
- {
- document.body.appendChild( this.m_oDatePickerDialog.m_oDialog.parentNode.removeChild( this.m_oDatePickerDialog.m_oDialog ) );
- oObj.m_bSetOnBody = true;
- }
-
- if ( (!this.m_oDatePickerDialog.isVisible()) )
- {
- this.positionDialog(oObj);
- }
-
- this.m_oDatePickerDialog.m_iUserDay = this.m_dDate.getDate();
-
- this.m_oDatePickerDialog.toggleDatePicker();
- }
- function CDatePicker_positionDialog(v_oObj)
- {
- var v_oDialog = this.m_oDatePickerDialog.m_oDialog;
- var v_sDisplayVal = v_oDialog.style.display;
- v_oDialog.style.display = "inline";
-
- var v_elRVReport = document.documentElement.querySelector(".RVReport") || document.documentElement;
-
- var v_oPageOffset;
- if (window.edge === true){
- v_oPageOffset = {x: v_elRVReport.scrollLeft, y: document.body.scrollTop};
- }
- else{
- v_oPageOffset = {x: v_elRVReport.scrollLeft, y: v_elRVReport.scrollTop};
- }
-
- var v_oObjRect = v_oObj.getBoundingClientRect();
- var v_oDialogRect = v_oDialog.getBoundingClientRect();
- var v_oClientRect = v_elRVReport.getBoundingClientRect();
-
- v_oDialog.style.display = v_sDisplayVal;
-
- var v_oPos = {x: v_oPageOffset.x, y: v_oPageOffset.y};
-
- if (v_oObjRect.top > 0)
- {
- if (v_oObjRect.top + v_oDialogRect.height <= v_oClientRect.height)
- {
- v_oPos.y += v_oObjRect.top;
- }
- else if (v_oObjRect.top + v_oDialogRect.height - v_oClientRect.height < v_oObjRect.top)
- {
- v_oPos.y += v_oClientRect.height - v_oDialogRect.height;
- }
- }
-
- if (v_oObjRect.left > 0)
- {
- if (v_oObjRect.left + v_oDialogRect.width <= v_oClientRect.width)
- {
- v_oPos.x += v_oObjRect.left;
- }
- else if (v_oObjRect.left + v_oDialogRect.width - v_oClientRect.width < v_oObjRect.left)
- {
- v_oPos.x += v_oClientRect.width - v_oDialogRect.width;
- }
- }
-
- if (this.m_isNS7 === true || window.edge === true)
- {
- v_oDialog.style.left = v_oPos.x + "px";
- v_oDialog.style.top = v_oPos.y + "px";
- }
- else
- {
- v_oDialog.style.pixelLeft = v_oPos.x;
- v_oDialog.style.pixelTop = v_oPos.y;
- }
- }
- function CDatePicker_checkDatePass(oEditBox)
- {
- if (this.m_oImgCheckDate && (this.m_oImgCheckDate.src != this.m_oImgErrorFalse.src))
- {
- this.m_oImgCheckDate.src = this.m_oImgErrorFalse.src;
- }
- if (oEditBox)
- {
- oEditBox.className = "clsSelectDateEditBox";
- PRMTUtils.f_showARIAPass(oEditBox, this.m_sRef);
- }
- this.notify(gPASS, this);
- this.checkData();
- }
- function CDatePicker_checkDateFail(oEditBox)
- {
- if (this.m_oImgCheckDate && (this.m_oImgCheckDate.src != this.m_oImgErrorTrue.src))
- {
- this.m_oImgCheckDate.src = this.m_oImgErrorTrue.src;
- }
- if (oEditBox)
- {
- oEditBox.className = "clsSelectDateEditBoxParseError";
- var v_emptyValue = sStripNonAlphanumerics(oEditBox.value) === K_PRMT_sEMPTY;
- var v_errorMsg = v_emptyValue ? PMT_UIM_MISSING_VALUE : PMT_UIM_INVALID_INPUT;
- PRMTUtils.f_showARIAFail(oEditBox, this.m_sRef, this.m_sSkin, v_errorMsg);
- }
- this.notify(gFAIL, this);
- this.checkData();
- }
- function CDatePicker_checkDate(oEditBox)
- {
- var bTestResult = true;
-
- var sTestDateStrip = sStripNonAlphanumerics(oEditBox.value).f_trim();
-
- if (this.m_iDateTimeType === 0)
- {
-
- var arSplitValue = sTestDateStrip.split(/T(?=\d)/);
- sTestDateStrip = arSplitValue[0];
- }
-
- if ( this.m_bRequired === false && sTestDateStrip === K_PRMT_sEMPTY)
- {
- this.m_dDate = null;
- this.updateFormVariable(this.m_oForm, this.m_dDate);
- this.m_bValid = true;
- this.checkDatePass(oEditBox);
- return;
- }
- var iTestDate = false;
-
- var tempInputOrder = this.m_sInputOrder;
- if(oEditBox == this.m_oForm)
- {
- tempInputOrder = "YMD";
- }
- if (this.m_iType === 1)
- {
- iTestDate = dParseEra(sTestDateStrip, tempInputOrder);
- }
- else
- {
- iTestDate = dParseDate(sTestDateStrip,tempInputOrder);
- }
-
- if (!iTestDate)
- {
- bTestResult = false;
- }
-
- if (bTestResult === false)
- {
- this.m_bValid = false;
- this.checkDateFail(oEditBox);
- return;
- }
- else
- {
-
- var dTestDate = iTestDate;
-
-
- if (this.m_dFirstDate)
- {
- if (dTestDate < this.m_dFirstDate)
- {
- this.m_bValid = false;
- this.checkDateFail(oEditBox);
- return;
- }
- }
-
-
- if (this.m_dLastDate)
- {
- if (dTestDate > this.m_dLastDate)
- {
- this.m_bValid = false;
- this.checkDateFail(oEditBox);
- return;
- }
- }
- this.m_dDate = dTestDate;
- this.m_bValid = true;
- this.updateFormVariable(this.m_oForm, this.m_dDate);
- this.checkDatePass(oEditBox);
- return;
- }
- }
- function CDatePicker_keyPress(evt)
- {
-
- evt = (evt) ? evt : ((event) ? event : null);
- if (evt)
- {
- var keyCode = (evt.keyCode) ? evt.keyCode : evt.which;
- if (keyCode=='8')
- {
-
- this.checkDate(this.m_oEditBox);
- }
- }
- return true;
- }
- function CDatePicker_gotFocus()
- {
-
- this.m_oDatePickerDialog.hidePicker();
- }
- function CDatePicker_lostFocus()
- {
- this.checkDate(this.m_oEditBox);
-
-
- if (this.m_bValid === true)
- {
- this.drawDate();
- }
- }
- function CDatePicker_preProcess()
- {
- if (this.m_sSubmitType == K_PRMT_sXML)
- {
- var sURLValues = K_PRMT_sEMPTY;
- if ((this.m_oEditBox.value !== K_PRMT_sEMPTY) && (this.m_bDisabled!==true))
- {
- sURLValues += '<selectOption';
- sURLValues += ' displayValue="' + sXmlEncode(this.sGetFormatValue()) +'"';
- sURLValues += ' useValue="' + sXmlEncode(this.sGetValue()) +'"';
- sURLValues += ' selected="true" />';
- }
- addSelectChoices(this.m_oSubmit, sURLValues);
- }
- else
- {
- if (this.m_bDisabled !== true)
- {
- this.m_oSubmit.value = this.m_oForm.value;
- }
- else
- {
-
- this.m_oSubmit.value = K_PRMT_sEMPTY;
- }
- }
- }
- function CDatePicker_sGetValue()
- {
- this.checkDate(this.m_oEditBox);
- if (this.m_bValid === true)
- {
- return this.m_oForm.value;
- }
- else
- {
- return false;
- }
- }
- function CDatePicker_enable()
- {
- this.m_bDisabled = false;
- this.m_oDialog.style.filter = "none";
- this.m_oEditBox.style.filter = "none";
- PRMTUtils.f_removeClass( this.m_oDialog, "clsClockDisabled" );
- PRMTUtils.f_removeClass( this.m_oEditBox, "clsClockDisabled" );
- }
- function CDatePicker_disable()
- {
- this.m_bDisabled = true;
- this.m_oDialog.style.filter = "alpha(opacity=75)";
- this.m_oEditBox.style.filter = "alpha(opacity=75)";
- PRMTUtils.f_addClass( this.m_oDialog, "clsClockDisabled" );
- PRMTUtils.f_addClass( this.m_oEditBox, "clsClockDisabled" );
- }
- function CDatePicker_toggleDisable(bState)
- {
- if (this.isRequired() === false)
- {
- if (bState === false)
- {
- this.disable();
- }
- else
- {
- this.enable();
- }
- }
- }
- function CDatePicker_handleResize()
- {
- var o = document.getElementById(this.m_sRef + "imgPicker");
- if (o)
- {
- this.positionDialog(o);
- }
- }
- function CDatePicker_sGetFormatValue()
- {
- if (this.isValid() === true)
- {
- return getFormatDate (this.m_dDate, this.m_iType, this.m_sInputOrder);
- }
- else
- {
- return false;
- }
- }
- function CDatePicker_setValue(s)
- {
-
- this.m_dDate = dParseDate(s, "YMD");
-
- this.m_oDatePickerDialog.refreshDate(this.m_dDate);
-
- this.drawDate();
- this.checkDate(this.m_oEditBox);
- }
- function CDatePicker_hasValue()
- {
- if (this.m_oForm.value === K_PRMT_sEMPTY)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- function CDatePicker_handleNotify()
- {
-
- if (this.m_iInline === 0)
- {
- this.m_oDatePickerDialog.hidePicker();
- }
- }
- function CDatePicker_checkFail()
- {
- this.checkDateFail(this.m_oEditBox);
- }
- CDatePicker.prototype.drawDate = CDatePicker_drawDate;
- CDatePicker.prototype.toggleDialogDatePicker= CDatePicker_toggleDialogDatePicker;
- CDatePicker.prototype.updateFormVariable = CDatePicker_updateFormVariable;
- CDatePicker.prototype.checkDate = CDatePicker_checkDate;
- CDatePicker.prototype.checkDateFail = CDatePicker_checkDateFail;
- CDatePicker.prototype.checkDatePass = CDatePicker_checkDatePass;
- CDatePicker.prototype.keyPress = CDatePicker_keyPress;
- CDatePicker.prototype.gotFocus = CDatePicker_gotFocus;
- CDatePicker.prototype.lostFocus = CDatePicker_lostFocus;
- CDatePicker.prototype.preProcess = CDatePicker_preProcess;
- CDatePicker.prototype.sGetValue = CDatePicker_sGetValue;
- CDatePicker.prototype.enable = CDatePicker_enable;
- CDatePicker.prototype.disable = CDatePicker_disable;
- CDatePicker.prototype.toggleDisable = CDatePicker_toggleDisable;
- CDatePicker.prototype.positionDialog = CDatePicker_positionDialog;
- CDatePicker.prototype.handleResize = CDatePicker_handleResize;
- CDatePicker.prototype.sGetFormatValue = CDatePicker_sGetFormatValue;
- CDatePicker.prototype.setValue = CDatePicker_setValue;
- CDatePicker.prototype.hasValue = CDatePicker_hasValue;
- CDatePicker.prototype.handleNotify = CDatePicker_handleNotify;
- CDatePicker.prototype.checkFail = CDatePicker_checkFail;
- CDatePicker.prototype.checkData = function()
- {
- if (this.m_oParent && !this.m_oParent.m_bisGetValuesCall) {
- this.m_oParent.checkData();
- }
- };
- CDatePicker.prototype.f_getPosY = function(v_oObj, v_bCC_offset)
- {
- var iYpos = 0;
- if (this.m_isNS7 && !v_bCC_offset)
- {
- iYpos = v_oObj.y;
-
- var oParent = v_oObj;
- while (oParent = oParent.offsetParent)
- {
- if (oParent.style && oParent.style.position == "relative")
- {
- iYpos += oParent.offsetTop;
- }
- }
- if (!iYpos) {
- iYpos = iOffsetFromBodyY(v_oObj);
- }
- }
- else
- {
- iYpos = iOffsetFromBodyY(v_oObj);
- }
- return iYpos;
- };
|