12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040 |
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| BI and PM: prmt
- *| (C) Copyright IBM Corp. 2002, 2021
- *|
- *| US Government Users Restricted Rights - Use, duplication or
- *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *|
- *+------------------------------------------------------------------------+
- */
- /*
- CDatePickerDialogIE5.js
- This script defines the properties and methods available to a popup dialog picker
- for the Date prompt control.
- */
- //Constructor to create a new Date Picker Dialog / inline calendar
- // oDialog: the id of html container for the date picker
- // oParentControl: the Date Picker object
- // sRef: string, the name of the parent object
- // bInline: boolean, 0= popup , 1= inline calendar
- // iType: integer, 0= gregorian, 1= japanese imperial
- // iStartOfWeek: start day of the week. sunday = 1, monday = 2, ..., saturday = 7
- function CDatePickerDialog(oDialog, oParentControl, sRef, bInline, iType, iStartOfWeek, sCVId, popupZIndex)
- {
-
- this.setCVId(sCVId);
- if (popupZIndex == null){
- this.popupZIndex="115";
- } else {
- this.popupZIndex = popupZIndex;
- }
- //the html dialog
- this.m_oDialog = oDialog;
-
- //the iframe
- this.m_iFrame = (browserIsNS7() ? null : document.getElementById("pickerControl" + sRef +"iframe"));
- //the parent control
- this.m_oParentControl = oParentControl;
- this.m_sRef = sRef; // the unique id appended to the each object
- this.m_oYearWidget = document.getElementById("myYear" + this.m_sRef);
- //is the control to be: rendered on the page (inline=1)
- //or as a popup (inline=0)
- this.m_bInline = bInline;
- //determine browser for DHTML type
- this.m_isNS7 = browserIsNS7();
- //draw the localized months
- this.initMonths();
- //sunday = 1, monday = 2, ..., saturday = 7
- this.m_iStartOfWeek = iStartOfWeek;
- //draw the days of the week in the order specified
- this.initDays();
- //store the user selection, so that they can navigate through
- //months in a natural way, as months have different end days
- this.m_iUserDay = this.m_oParentControl.m_dDate.getDate();
- this.m_iType = iType;
-
- //will be used to store event listeners on the days.
- this.m_aHandles = [];
-
- if (!this.m_bInline)
- {
- this.m_oDialog.style.position = "absolute";
- this.m_oDialog.style.display = "none";
- this.m_oDialog.style.zIndex = this.popupZIndex;
- var v_divPicker = document.getElementById("dialogDatePicker" + this.m_sRef);
- if (v_divPicker)
- {
- PRMTUtils.f_addEvent( v_divPicker, "click",
- function(v_oEvent){
- PRMTUtils.F_StopEvent(v_oEvent);
- }
- );
- }
- if (document && document.body && (!document.body.oDatePickerHandler || document.body.oDatePickerHandler[sCVId]!== true))
- {
- if (!document.body.oDatePickerHandler) {
- document.body.oDatePickerHandler = [sCVId];
- }
- var aDatePickersObservers = this.getObserverArray('datePickerObserverArray');
- document.body.oDatePickerHandler[sCVId] = true;
- PRMTUtils.f_addEvent( document.body, "click",
- function(v_oEvent){
- v_oEvent = (v_oEvent ? v_oEvent : event);
- var v_oTarget = (v_oEvent.target ? v_oEvent.target : v_oEvent.srcElement);
- if ( !(v_oTarget && v_oTarget.tagName == "IMG" && v_oTarget.src && v_oTarget.src.match(/icon_datepicker.gif/i)) )
- {
- datePickerObserverNotify(aDatePickersObservers);
- }
- }
- );
- }
- }
- else
- {
- //refresh the date
- this.refreshDate(this.m_oParentControl.m_dDate);
- this.m_oDialog.style.visibility = "inherit";
- }
- }
- CDatePickerDialog.prototype = new CPromptControl();
- //show and hide the dialog
- function CDatePickerDialog_toggleDatePicker()
- {
- //an iframe is used to prevent HTML controls from bleeding through the dialogs (IE only).
- var v_elIFrame = this.m_iFrame;
-
- //show the dialog if not already visible
- if ( this.isVisible() )
- {
- this.m_oDialog.style.display = "none";
- this.m_oDialog.style.zIndex = "1";
- if ( v_elIFrame !== null )
- {
- v_elIFrame.style.display = "none";
- }
- }
- else
- {
- //notify any date pickers that may already be open
- datePickerObserverNotify();
-
- //show the dialog
- this.m_oDialog.style.display = "inline";
- this.m_oDialog.style.zIndex = this.popupZIndex;
- var sId = "btnYearDown" + this.m_sRef;
- var focusEl = document.getElementById(sId);
- if (focusEl != null){
- window.setTimeout("document.getElementById('" + sId + "').focus();", 500);
- }
- //IE 5.0 has opaque iframes, for IE5.5 and above,
- //the iframe can be used to mask components that
- //bleed through a div element
- if (v_elIFrame !== null && typeof v_elIFrame.allowTransparency != K_PRMT_sUNDEFINED)
- {
- //move the iframe
- this.resizeIframe(v_elIFrame, this.m_oDialog);
- v_elIFrame.style.zIndex = "1";
- v_elIFrame.style.display = "inline";
- }
- }
-
- }
- //hide the dialog
- function CDatePickerDialog_hidePicker()
- {
- var v_iframe = this.m_iFrame;
- this.m_oDialog.style.display = "none";
- //an iframe is used to prevent HTML controls from bleeding through the dialogs
- if ( v_iframe !== null && v_iframe.style )
- {
- v_iframe.style.display = "none";
- }
-
- }
- function CDatePickerDialog_isVisible()
- {
- return ( this.m_oDialog.style.display == "inline" );
- }
- //render the control with a new date
- function CDatePickerDialog_refreshDate(dNewDate)
- {
- if (!dNewDate)
- {
- //if there is no date, default to today date
- var d = new Date();
- dNewDate = d;
- this.m_oParentControl.m_dDate = d;
- }
- //calculate the number of days in the month and see
- //if the user selection is valid
- var iMaxDays = intGetDays(dNewDate.getMonth(), dNewDate.getFullYear());
- this.m_iUserDay = dNewDate.getDate();
- if (this.m_iUserDay > iMaxDays)
- {
- dNewDate.setDate(iMaxDays);
- }
- else
- {
- dNewDate.setDate(this.m_iUserDay);
- }
- // 0 = standard ; 1 = japaneseEmperor
- if (this.m_iType == 1)
- {
- this.drawEmperorYear(dNewDate);
- }
- else
- {
- this.drawYear(dNewDate);
- }
- this.refreshPickerLayout(dNewDate);
- }
- function CDatePickerDialog_refreshPickerLayout(dNewDate)
- {
- //update the form control
- this.m_oParentControl.updateFormVariable(this.m_oParentControl.m_oForm, dNewDate);
- this.clearMonths();
- this.clearDays();
- this.drawMonth(dNewDate.getMonth());
- this.drawDays(dNewDate);
- this.refreshPickerIFrame();
- }
- function CDatePickerDialog_refreshPickerIFrame()
- {
- if (this.m_iFrame !== null)
- {
- //an iframe is used to prevent HTML controls from bleeding through the dialogs
- this.resizeIframe(this.m_iFrame, this.m_oDialog);
- }
- }
- //increment the year by 1
- function CDatePickerDialog_yearUp()
- {
- var dNewDate = new Date ();
- dNewDate.setDate(1);
- dNewDate.setMonth(this.m_oParentControl.m_dDate.getMonth());
- var sCurYear = this.m_oParentControl.m_dDate.getFullYear();
- dNewDate.setFullYear(sCurYear +1);
- //check the number of days in the month
- var iMaxDays = intGetDays(dNewDate.getMonth(), dNewDate.getFullYear());
- if (this.m_iUserDay > iMaxDays)
- {
- dNewDate.setDate(iMaxDays);
- }
- else
- {
- dNewDate.setDate(this.m_iUserDay);
- }
- //enforce first and last dates
- //check to see if this date less than the first date
- //if so, then this is not a valid date
- if (this.m_oParentControl.m_dFirstDate)
- {
- if (bIsDateEarlier(dNewDate, this.m_oParentControl.m_dFirstDate) === true)
- {
- return;
- }
- }
- //check to see if this date is greater than the last date
- //if so, then this is not a valid date
- if (this.m_oParentControl.m_dLastDate)
- {
- if (bIsDateLater(dNewDate, this.m_oParentControl.m_dLastDate) === true)
- {
- //if the years are the same then see if a new month and day should be picked
- if (dNewDate.getYear() == this.m_oParentControl.m_dLastDate.getYear())
- {
- dNewDate.setMonth(this.m_oParentControl.m_dLastDate.getMonth());
- dNewDate.setDate(this.m_oParentControl.m_dLastDate.getDate());
- }
- else
- {
- return;
- }
- }
- }
- //update the date
- this.m_oParentControl.m_dDate = dNewDate;
- //redraw the dialog
- this.refreshDate(this.m_oParentControl.m_dDate);
- //repaint date control
- this.m_oParentControl.drawDate();
- //update the parent control and check the date
- this.m_oParentControl.checkDate(this.m_oParentControl.m_oEditBox);
- }
- //increment the year down by 1
- function CDatePickerDialog_yearDown()
- {
- var dNewDate = new Date ();
- dNewDate.setDate(1);
- dNewDate.setMonth(this.m_oParentControl.m_dDate.getMonth());
- var sCurYear = this.m_oParentControl.m_dDate.getFullYear();
- //Do not do decrease the year by 1 if it's already 0.
- if (parseInt(sCurYear, 10) <= 0)
- {
- return;
- }
- dNewDate.setFullYear(sCurYear -1);
- var iMaxDays = intGetDays(dNewDate.getMonth(), dNewDate.getFullYear());
- if (this.m_iUserDay > iMaxDays)
- {
- dNewDate.setDate(iMaxDays);
- }
- else
- {
- dNewDate.setDate(this.m_iUserDay);
- }
- //enforce first and last dates
- //check to see if this date less than the first date
- //if so, then this is not a valid date
- if (this.m_oParentControl.m_dFirstDate)
- {
- if (bIsDateEarlier(dNewDate, this.m_oParentControl.m_dFirstDate) === true)
- {
- if (bIsDateEarlier(dNewDate, this.m_oParentControl.m_dFirstDate) === true)
- {
- //if the years are the same then see if a new month and day should be picked
- if (dNewDate.getYear() == this.m_oParentControl.m_dFirstDate.getYear())
- {
- dNewDate.setMonth(this.m_oParentControl.m_dFirstDate.getMonth());
- dNewDate.setDate(this.m_oParentControl.m_dFirstDate.getDate());
- }
- else
- {
- return;
- }
- }
- }
- }
- //check to see if this date is greater than the last date
- //if so, then this is not a valid date
- if (this.m_oParentControl.m_dLastDate)
- {
- if (bIsDateLater(dNewDate, this.m_oParentControl.m_dLastDate) === true)
- {
- return;
- }
- }
- //update the date
- this.m_oParentControl.m_dDate = dNewDate;
- //redraw the dialog
- this.refreshDate(this.m_oParentControl.m_dDate);
- //repaint date control
- this.m_oParentControl.drawDate();
- //update the parent control and check the date
- this.m_oParentControl.checkDate(this.m_oParentControl.m_oEditBox);
- }
- //initialize the months
- function CDatePickerDialog_initMonths()
- {
- for(var i=0;i<12;i++)
- {
- var idMonthWidget = this.m_sRef+"m"+i;
- var oMonthWidget = document.getElementById(idMonthWidget);
- oMonthWidget.innerHTML = sGetMonth(i);
- }
- }
- //initialize the days
- function CDatePickerDialog_initDays()
- {
- //there are 7 spots for the days
- //start from the startDayOffset, then wrap to finish the beginning
- //convert to the start from zero to properly access the array.
- var iDayOfWeek = this.m_iStartOfWeek -1;
- var idDayWidget = null;
- var oDayWidget = null;
- for(var i=0;i + iDayOfWeek < 7 ;i++)
- {
- var iDayOffset = i + iDayOfWeek;
- idDayWidget = this.m_sRef+"d"+i;
- oDayWidget = document.getElementById(idDayWidget);
- oDayWidget.innerHTML = sGetDay(iDayOffset);
- }
- for (i=0; i < iDayOfWeek; i++)
- {
- idDayWidget = this.m_sRef+"d"+(7 - iDayOfWeek + i);
- oDayWidget = document.getElementById(idDayWidget);
- oDayWidget.innerHTML = sGetDay(i);
- }
- }
- //Draw the year in the standard way
- function CDatePickerDialog_drawYear(dNewDate)
- {
- var sYear = dNewDate.getFullYear();
- sYear = "0000" + sYear;
- sYear = sYear.substring(sYear.length-4, sYear.length);
- this.m_oYearWidget.value = sYear;
- }
- //draw the year in Japanese Emperor Time
- function CDatePickerDialog_drawEmperorYear(dNewDate)
- {
- var sEmperorYear = getJapaneseEra (dNewDate);
- this.m_oYearWidget.value = sEmperorYear;
- }
- //change the month
- function CDatePickerDialog_newMonth(iMonth)
- {
- //check the number of days in the month
- var iMaxDays = intGetDays(iMonth, this.m_oParentControl.m_dDate.getFullYear());
- var useDay;
- if (this.m_iUserDay > iMaxDays)
- {
- useDay = iMaxDays;
- }
- else
- {
- useDay = this.m_iUserDay;
- }
- //set the day and month after the day is taken care of
- var dNewDate = new Date (this.m_oParentControl.m_dDate.getFullYear(), iMonth, useDay);
- //set the year using the function "setFullYear" to completely make sure correct year is set for dNewDate
- dNewDate.setFullYear(this.m_oParentControl.m_dDate.getFullYear());
- //enforce first and last dates
- //check to see if this date less than the first date
- //if so, then this is not a valid date
- if (this.m_oParentControl.m_dFirstDate)
- {
- if (bIsDateEarlier(dNewDate, this.m_oParentControl.m_dFirstDate) === true)
- {
- //if the months are the same then see if a new day should be picked
- if (dNewDate.getMonth() == this.m_oParentControl.m_dFirstDate.getMonth())
- {
- var testDay = this.m_oParentControl.m_dFirstDate.getDate();
- if ((useDay < testDay) && (testDay <= iMaxDays))
- {
- dNewDate.setDate(testDay);
- }
- }
- else
- {
- return;
- }
- }
- }
- //check to see if this date is greater than the last date
- //if so, then this is not a valid date
- if (this.m_oParentControl.m_dLastDate)
- {
- if (bIsDateLater(dNewDate, this.m_oParentControl.m_dLastDate) === true)
- {
- //if the months are the same then see if a new day should be picked
- if (dNewDate.getMonth() == this.m_oParentControl.m_dLastDate.getMonth())
- {
- var testDay = this.m_oParentControl.m_dLastDate.getDate();
- if ((useDay > testDay) && (testDay <= iMaxDays))
- {
- dNewDate.setDate(testDay);
- }
- }
- else
- {
- return;
- }
- }
- }
- this.m_oParentControl.m_dDate = dNewDate;
- //redraw the control
- this.refreshDate(this.m_oParentControl.m_dDate);
- //update the parent control
- this.m_oParentControl.drawDate();
- //update the parent control and check the date
- this.m_oParentControl.checkDate(this.m_oParentControl.m_oEditBox);
- }
- //clear the months
- function CDatePickerDialog_clearMonths()
- {
- var iCurMonth=0;
- for (iCurMonth=0; iCurMonth <12; iCurMonth++)
- {
- var idCurMonthWidget = this.m_sRef+"m"+iCurMonth;
- //reset element
- document.getElementById(idCurMonthWidget).className = "clsSelectDateMonths pm";
- }
- }
- //render the selected month
- function CDatePickerDialog_drawMonth(iMonth)
- {
- //are there days in this month that might be
- //too early or too late
- var bValuesEarlier = false;
- var bValuesLater = false;
- var currentYear = this.m_oParentControl.m_dDate.getFullYear();
- if (this.m_oParentControl.m_dFirstDate)
- {
- if (currentYear <= this.m_oParentControl.m_dFirstDate.getFullYear())
- {
- bValuesEarlier = true;
- }
- }
- if (this.m_oParentControl.m_dLastDate)
- {
- if (currentYear >= this.m_oParentControl.m_dLastDate.getFullYear())
- {
- bValuesLater = true;
- }
- }
- //loop through the table
- for (var c = 0; c < 12; c++)
- {
- var iMonthWidget = this.m_sRef+"m"+c;
- // make bold if this is the current month
- if (iMonth == c)
- {
- document.getElementById(iMonthWidget).className = "clsSelectDateMonthsSelected pms";
- document.getElementById(iMonthWidget).setAttribute("aria-selected","true");
- document.getElementById(iMonthWidget).setAttribute("tabindex","0");
- document.getElementById(iMonthWidget).setAttribute("role","option");
- }
- //if the current year is less than or equal to the first year
- //then we have to worry about some months that may not be valid
- //get the number of days for each month and compare with the first date
- else if ((bValuesEarlier === true) && ( bIsDateEarlier(new Date(currentYear, c, intGetDays(c, currentYear)), this.m_oParentControl.m_dFirstDate) === true ))
- {
- document.getElementById(iMonthWidget).className = "clsSelectDateMonthsDisabled pmd";
- document.getElementById(iMonthWidget).setAttribute("aria-selected","false");
- document.getElementById(iMonthWidget).setAttribute("tabindex","0");
- document.getElementById(iMonthWidget).setAttribute("role","option");
- }
- else if ((bValuesLater === true) && (bIsDateLater(new Date(currentYear, c, 1), this.m_oParentControl.m_dLastDate) === true ))
- {
- document.getElementById(iMonthWidget).className = "clsSelectDateMonthsDisabled pmd";
- document.getElementById(iMonthWidget).setAttribute("aria-selected","false");
- document.getElementById(iMonthWidget).setAttribute("tabindex","0");
- document.getElementById(iMonthWidget).setAttribute("role","option");
- }
- else
- {
- document.getElementById(iMonthWidget).className = "clsSelectDateMonths pm";
- document.getElementById(iMonthWidget).setAttribute("aria-selected","false");
- document.getElementById(iMonthWidget).setAttribute("tabindex","0");
- document.getElementById(iMonthWidget).setAttribute("role","option");
- }
- }
- }
- //change the day
- function CDatePickerDialog_newDay(oDayObj)
- {
- var iNewDay = parseInt(oDayObj.innerHTML,10);
- //check to see if this is a valid day
- if (!isNaN(iNewDay))
- {
- //update the user selection
- this.m_iUserDay = iNewDay;
- var dNewDate = new Date ();
- dNewDate.setDate(1);
- dNewDate.setMonth(this.m_oParentControl.m_dDate.getMonth());
- dNewDate.setFullYear(this.m_oParentControl.m_dDate.getFullYear());
- dNewDate.setDate(iNewDay);
- //enforce first and last dates
- //check to see if this date less than the first date
- //if so, then this is not a valid date
- if (this.m_oParentControl.m_dFirstDate)
- {
- if (bIsDateEarlier(dNewDate, this.m_oParentControl.m_dFirstDate) === true)
- {
- return;
- }
- }
- //check to see if this date is greater than the last date
- //if so, then this is not a valid date
- if (this.m_oParentControl.m_dLastDate)
- {
- if (bIsDateLater(dNewDate, this.m_oParentControl.m_dLastDate) === true)
- {
- return;
- }
- }
- //update the date
- this.m_oParentControl.m_dDate = dNewDate;
- this.refreshDate(this.m_oParentControl.m_dDate);
- //update the parent control
- this.m_oParentControl.drawDate();
- //toggle the picker control if it is a popup control
- if (!this.m_bInline)
- {
- this.hidePicker();
- window.setTimeout("document.getElementById('txtDate" + this.m_sRef +"').focus();",500);
- }
- }
- //update the parent control and check the date
- this.m_oParentControl.checkDate(this.m_oParentControl.m_oEditBox);
- }
- function CDatePickerDialog_drawDays(dCurDate)
- {
- //clear the days before drawing new days
- this.clearDays();
-
- //determine the day of the week the month starts on
- var dBeginDay = new Date (dCurDate.getFullYear(),dCurDate.getMonth(),1);
- //Sunday is 0, Monday is 1, Saturday is 6
- var iBeginDayDate = dBeginDay.getDay();
- //calculate the number of days in the month
- var iCountDay = intGetDays(dCurDate.getMonth(), dCurDate.getFullYear());
- var iTestDay = dCurDate.getDate();
- //define counters
- var i=0;
- var j=0;
- //figure out what slot to start the month in
- var iStartCell = iBeginDayDate - this.m_iStartOfWeek + 1;
- if ( iStartCell > 0 )
- {
- i = iStartCell;
- }
- else if ( iStartCell === 0)
- {
- i = 0;
- }
- else
- {
- i = 7 + iStartCell;
- }
- //are there days in this month that might be
- //too early or too late
- var bValuesEarlier = false;
- var bValuesLater = false;
- if (this.m_oParentControl.m_dFirstDate)
- {
- if (bIsDateEarlier(dBeginDay, this.m_oParentControl.m_dFirstDate) === true)
- {
- bValuesEarlier = true;
- }
- }
- var dEndDay = new Date (dCurDate.getFullYear(),dCurDate.getMonth(),iCountDay);
- //check to see if this date is greater than the last date
- //if so, then this is not a valid date
- if (this.m_oParentControl.m_dLastDate)
- {
- if (bIsDateLater(dEndDay, this.m_oParentControl.m_dLastDate) === true)
- {
- bValuesLater = true;
- }
- }
- //loop through the table
- var oColumnName;
- var idCurDayWidget;
- var firstStart = true;
- for (var c=1;c < iCountDay +1;c++)
- {
- //determine the correct column
- if ( this.m_isNS7 )
- {
- idCurDayWidget = this.m_sRef+"r"+j+"c"+i;
- oColumnName = document.getElementById(idCurDayWidget);
- }
- else
- {
- if ( i === 0 || firstStart )
- {
- idCurDayWidget = this.m_sRef+"r"+j+"c"+i;
- oColumnName = document.getElementById(idCurDayWidget);
- }
- else
- {
- oColumnName = oColumnName.nextSibling;
- }
- firstStart = false;
- }
- oColumnName.innerHTML = c;
- oColumnName.setAttribute("role","option");
- oColumnName.setAttribute("aria-describedby",this.m_sRef + "d" + i);
- this.addEventListenerForDay(oColumnName, "mousedown", this.newDay.bind(this, oColumnName));
- var calendarComp=this;
- if (c == iCountDay) {
- this.addEventListenerForDay( oColumnName, "keydown",function (e) {if ((e.keyCode == 9)&&(!e.shiftKey)){if (calendarComp.checkTabFocus(this)){PRMTUtils.F_StopEvent(e);}} else if ((e.keyCode == 13) || (e.keyCode == 32)) {calendarComp.newDay(this);}});
- } else {
- this.addEventListenerForDay( oColumnName, "keydown",function (e) {if ((e.keyCode == 13) || (e.keyCode == 32)) {calendarComp.newDay(this);}});
- }
-
- oColumnName.setAttribute("tabindex","0");
- //shade the selected color
- if (c == iTestDay)
- {
- oColumnName.className = "clsSelectDateDaysSelected pds";
- oColumnName.setAttribute("aria-selected", "true");
- }
- //check to see if the day is in the valid range
- else if ((bValuesEarlier === true) && (c < this.m_oParentControl.m_dFirstDate.getDate()))
- {
- oColumnName.className = "clsSelectDateDaysDisabled pdd";
- oColumnName.setAttribute("aria-selected", "false");
- oColumnName.setAttribute("tabindex", "0");
- oColumnName.setAttribute("role", "option");
- }
- else if ((bValuesLater === true) && (c > this.m_oParentControl.m_dLastDate.getDate()))
- {
- oColumnName.className = "clsSelectDateDaysDisabled pdd";
- oColumnName.setAttribute("aria-selected", "false");
- oColumnName.setAttribute("tabindex", "0");
- oColumnName.setAttribute("role", "option");
-
- }
- else
- {
- oColumnName.className = "clsSelectDateDays pd";
- oColumnName.setAttribute("aria-selected", "false");
- oColumnName.setAttribute("tabindex", "0");
- oColumnName.setAttribute("role", "option");
-
- }
- //increment the day counter
- i++;
- //check to see if finished the row
- if (i==7){i=0;j++;}
- }
- }
- //remove the days from the calendar picker
- function CDatePickerDialog_clearDays()
- {
- var idCurDayWidget;
- var oColumnName;
- var curWeek;
- if ( !this.m_isNS7 )
- {
- idCurDayWidget = this.m_sRef+"r"+0+"c"+0;
- oColumnName = document.getElementById(idCurDayWidget);
- curWeek = oColumnName.parentElement;
- }
-
- // RTC Story 373917 [Web a11y] Make the Date prompt accessible
- // Must remove the event handlers so that they do not get regisered multiple times
- this.removeEventListenersFromDays();
-
- var i = 0;
- for(var j=0;j<6;j++)
- {
- if ( this.m_isNS7 )
- {
- for(i=0;i<7;i++)
- {
- idCurDayWidget = this.m_sRef+"r"+j+"c"+i;
- oColumnName = document.getElementById(idCurDayWidget);
- oColumnName.removeAttribute("tabindex");
- oColumnName.removeAttribute("role");
- oColumnName.removeAttribute("aria-selected");
- oColumnName.innerHTML = K_PRMT_sEMPTY;
- oColumnName.className = "clsSelectDate";
- }
- }
- else
- {
- var aDay = curWeek.firstChild;
- for(i=0;i<7;i++)
- {
- aDay.innerHTML = K_PRMT_sEMPTY;
- aDay.className = "clsSelectDate";
- aDay = aDay.nextSibling;
- }
- curWeek = curWeek.nextSibling;
- }
- }
- }
- function CDatePickerDialog_addEventListenerForDay(v_oElement, v_sEvent, v_fnListener)
- {
- if ( v_oElement )
- {
- if ( v_oElement.addEventListener )
- {
- v_oElement.addEventListener( v_sEvent, v_fnListener, false );
- this.m_aHandles.push({remove: function() { v_oElement.removeEventListener(v_sEvent, v_fnListener, false); }});
- }
- else
- {
- v_oElement.attachEvent( 'on' + v_sEvent, v_fnListener );
- this.m_aHandles.push({remove: function() { v_oElement.detachEvent('on' + v_sEvent, v_fnListener); }});
- }
- }
- }
- function CDatePickerDialog_removeEventListenersFromDays()
- {
- while (this.m_aHandles.length > 0)
- {
- var v_oHandle = this.m_aHandles.pop();
- v_oHandle.remove();
- }
- }
- //render the check date pass state
- function CDatePickerDialog_checkDatePass(oEditBox)
- {
- oEditBox.className = "clsSelectDateYearEditBox";
- this.m_oParentControl.checkDatePass(null);
-
- this.notify(gPASS, this);
- }
- //render the check date failure state
- function CDatePickerDialog_checkDateFail(oEditBox)
- {
- oEditBox.className = "clsSelectDateYearEditBoxParseError";
- this.m_oParentControl.checkDateFail(null);
- this.notify(gFAIL, this);
- }
- function CDatePickerDialog_getYearFromEditBox(oEditBox)
- {
- //check to see if this is a valid date
- var sTestYear = oEditBox.value;
- var iYear = false;
- if ( this.m_iType == 1 )
- {
- iYear = iTestEra(sTestYear);
- }
- else if ( boolTestYear(sTestYear) )
- {
- iYear = sTestYear;
- if (iYear.length == 2)
- {
- iYear = sShortToFullYearConversion(iYear);
- }
- }
- return iYear;
- }
- //test the year
- function CDatePickerDialog_checkYear(oEditBox)
- {
- //check to see if this is a valid date
- var iYear = this.getYearFromEditBox(oEditBox);
- if ( iYear === false )
- {
- this.checkDateFail(oEditBox);
- }
- else
- {
- this.checkDatePass(oEditBox);
- var v_oParentControl = this.m_oParentControl;
- var v_oParentControlDate = v_oParentControl.m_dDate;
- v_oParentControlDate.setFullYear(iYear);
- if (this.m_iType == 1)
- {
- // using emperor time
- // refreshDate() will call refreshPickerLayout()
- this.refreshDate(v_oParentControlDate);
- }
- else
- {
- this.refreshPickerLayout(v_oParentControlDate);
- }
- //draw months and days
- v_oParentControl.drawDate();
- v_oParentControl.checkDate(v_oParentControl.m_oEditBox);
- }
- }
- //catch the backspace key
- //some browsers (IE5.5 don't capture this event)
- function CDatePickerDialog_keyPress(sKeyCode)
- {
- if (sKeyCode=='8')
- {
- //check the data that has been typed in
- this.checkYear(this.m_oYearWidget);
- }
- return true;
- }
- //handle lost focus for the control
- function CDatePickerDialog_lostFocus()
- {
- //redraw the date
- this.refreshDate(this.m_oParentControl.m_dDate);
- this.m_oParentControl.drawDate();
- this.checkDatePass(this.m_oYearWidget);
- }
- //handle reset focus to popup button if necessary to keep the focus inside the popup
- function CDatePickerDialog_checkTabFocus()
- {
- if (!this.m_bInline)
- {
- var btnYearDownButton = document.getElementById("btnYearDown" + this.m_sRef);
- if (btnYearDownButton != null){
- btnYearDownButton.focus();
- return true;
- }
- } else {
- var pickerButton = document.getElementById(this.m_sRef + "imgPicker");
- if (pickerButton != null){
- pickerButton.focus();
- return true;
- }
- }
- return false;
- }
- //IE specific, draw an iframe behind the date picker to
- //prevent bleed through of controls
- function CDatePickerDialog_resizeIframe(iframe, oDialog)
- {
- var v_oParent = iframe;
- while ( v_oParent = v_oParent.parentNode )
- {
- // Using CSS class "cogstyle-filter-body" to identify Cognos Admin filter pages.
- if ( v_oParent.className == "cogstyle-filter-body" )
- {
- // Bug 553594.1 - Date controls in the filter pane in CC aren't positioning themself correctly.
- // It conflicts with how the page is rendered by CC (other elements in the page are using position:relative)
- // which interfere with the pop-up calendar (or any element set with position:absolute).
- // Solution here is to leave the calendar under the input field rather than moving it under the icon that triggers
- // the pop-up dialog.
- return;
- }
- }
- if ( iframe.parentNode != oDialog.parentNode )
- {
- iframe.parentNode.removeChild(iframe);
- oDialog.parentNode.insertBefore(iframe, oDialog);
- }
- if (this.m_isNS7 === true)
- {
- iframe.style.left = oDialog.style.left;
- iframe.style.top = oDialog.style.top;
- iframe.style.width = oDialog.width;
- iframe.style.height = oDialog.height;
- }
- else
- {
- iframe.style.pixelLeft = oDialog.style.pixelLeft;
- iframe.style.pixelTop = oDialog.style.pixelTop;
- iframe.style.pixelWidth = oDialog.offsetWidth;
- iframe.style.pixelHeight = oDialog.offsetHeight;
- }
- }
- //Prototypes to assign methods to new instances of the object
- CDatePickerDialog.prototype.toggleDatePicker = CDatePickerDialog_toggleDatePicker;
- CDatePickerDialog.prototype.refreshDate = CDatePickerDialog_refreshDate;
- CDatePickerDialog.prototype.yearUp = CDatePickerDialog_yearUp;
- CDatePickerDialog.prototype.yearDown = CDatePickerDialog_yearDown;
- CDatePickerDialog.prototype.drawYear = CDatePickerDialog_drawYear;
- CDatePickerDialog.prototype.newMonth = CDatePickerDialog_newMonth;
- CDatePickerDialog.prototype.drawMonth = CDatePickerDialog_drawMonth;
- CDatePickerDialog.prototype.clearMonths = CDatePickerDialog_clearMonths;
- CDatePickerDialog.prototype.newDay = CDatePickerDialog_newDay;
- CDatePickerDialog.prototype.drawDays = CDatePickerDialog_drawDays;
- CDatePickerDialog.prototype.clearDays = CDatePickerDialog_clearDays;
- CDatePickerDialog.prototype.drawEmperorYear = CDatePickerDialog_drawEmperorYear;
- CDatePickerDialog.prototype.hidePicker = CDatePickerDialog_hidePicker;
- CDatePickerDialog.prototype.isVisible = CDatePickerDialog_isVisible;
- CDatePickerDialog.prototype.checkYear = CDatePickerDialog_checkYear;
- CDatePickerDialog.prototype.lostFocus = CDatePickerDialog_lostFocus;
- CDatePickerDialog.prototype.initMonths = CDatePickerDialog_initMonths;
- CDatePickerDialog.prototype.initDays = CDatePickerDialog_initDays;
- CDatePickerDialog.prototype.checkDateFail = CDatePickerDialog_checkDateFail;
- CDatePickerDialog.prototype.checkDatePass = CDatePickerDialog_checkDatePass;
- CDatePickerDialog.prototype.keyPress = CDatePickerDialog_keyPress;
- CDatePickerDialog.prototype.resizeIframe = CDatePickerDialog_resizeIframe;
- CDatePickerDialog.prototype.getYearFromEditBox = CDatePickerDialog_getYearFromEditBox;
- CDatePickerDialog.prototype.refreshPickerIFrame = CDatePickerDialog_refreshPickerIFrame;
- CDatePickerDialog.prototype.refreshPickerLayout = CDatePickerDialog_refreshPickerLayout;
- CDatePickerDialog.prototype.checkTabFocus = CDatePickerDialog_checkTabFocus;
- CDatePickerDialog.prototype.removeEventListenersFromDays = CDatePickerDialog_removeEventListenersFromDays;
- CDatePickerDialog.prototype.addEventListenerForDay = CDatePickerDialog_addEventListenerForDay;
|