Author: nbelaevski
Date: 2009-03-23 09:31:03 -0400 (Mon, 23 Mar 2009)
New Revision: 13098
Modified:
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
https://jira.jboss.org/jira/browse/RF-5211
Modified:
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
---
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2009-03-23
13:21:33 UTC (rev 13097)
+++
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2009-03-23
13:31:03 UTC (rev 13098)
@@ -1349,6 +1349,21 @@
return result;
},
+ setupTimeForDate: function (date) {
+ if (this.selectedDate && !this.params.resetTimeOnDateSelect ||
+ (this.selectedDate.getFullYear() == date.getFullYear() &&
+ this.selectedDate.getMonth() == date.getMonth() &&
+ this.selectedDate.getDate() == date.getDate()))
+ {
+ date.setHours(this.selectedDate.getHours());
+ date.setMinutes(this.selectedDate.getMinutes());
+ } else
+ {
+ date.setHours(this.params.defaultTime.hours);
+ date.setMinutes(this.params.defaultTime.minutes);
+ }
+ },
+
eventCellOnClick: function (e, obj) {
var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
if (daydata.enabled && daydata._month==0)
@@ -1357,15 +1372,7 @@
date.setDate(daydata.day);
if (this.timeType)
{
- if (this.selectedDate && !this.params.resetTimeOnDateSelect)
- {
- date.setHours(this.selectedDate.getHours());
- date.setMinutes(this.selectedDate.getMinutes());
- } else
- {
- date.setHours(this.params.defaultTime.hours);
- date.setMinutes(this.params.defaultTime.minutes);
- }
+ this.setupTimeForDate(date);
}
if (this.selectDate(date,true, {event:e, element:obj}) &&
!this.showApplyButton)
@@ -1381,15 +1388,7 @@
var date = new Date(daydata.date);
if (this.timeType)
{
- if (this.selectedDate && !this.params.resetTimeOnDateSelect)
- {
- date.setHours(this.selectedDate.getHours());
- date.setMinutes(this.selectedDate.getMinutes());
- } else
- {
- date.setHours(this.params.defaultTime.hours);
- date.setMinutes(this.params.defaultTime.minutes);
- }
+ this.setupTimeForDate(date);
}
if (this.selectDate(date, false, {event:e, element:obj}) &&
!this.showApplyButton)
@@ -1869,15 +1868,7 @@
var date = new Date(today.getFullYear(), today.getMonth(), today.getDate());
if (this.timeType)
{
- if (this.selectedDate && !this.params.resetTimeOnDateSelect)
- {
- date.setHours(this.selectedDate.getHours());
- date.setMinutes(this.selectedDate.getMinutes());
- } else
- {
- date.setHours(this.params.defaultTime.hours);
- date.setMinutes(this.params.defaultTime.minutes);
- }
+ this.setupTimeForDate(date);
}
if (daydata.enabled && this.selectDate(date,true) &&
!this.showApplyButton)
{