Author: pyaschenko
Date: 2007-09-27 11:38:31 -0400 (Thu, 27 Sep 2007)
New Revision: 3145
Modified:
trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
trunk/ui/calendar/src/main/config/component/calendar.xml
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
Log:
RF-978
Modified: trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
===================================================================
--- trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-09-27 14:18:56
UTC (rev 3144)
+++ trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-09-27 15:38:31
UTC (rev 3145)
@@ -57,7 +57,10 @@
valueChangeListener="#{calendarBean.ddd}"
reRender="counter"
inputClass="ic"
- buttonClass="bc">
+ buttonClass="bc"
+ horizontalOffset="3"
+ verticalOffset="3"
+ mode="ajax">
<f:facet name="optionalHeader">
<h:outputText value="optionalHeader Facet" />
</f:facet>
Modified: trunk/ui/calendar/src/main/config/component/calendar.xml
===================================================================
--- trunk/ui/calendar/src/main/config/component/calendar.xml 2007-09-27 14:18:56 UTC (rev
3144)
+++ trunk/ui/calendar/src/main/config/component/calendar.xml 2007-09-27 15:38:31 UTC (rev
3145)
@@ -324,6 +324,13 @@
</description>
</property>
<property>
+ <name>ondateselected</name>
+ <classname>java.lang.String</classname>
+ <description>
+ onDateSelected event handler
+ </description>
+ </property>
+ <property>
<name>oncurrentdateselect</name>
<classname>java.lang.String</classname>
<description>
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 2007-09-27
14:18:56 UTC (rev 3144)
+++
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-09-27
15:38:31 UTC (rev 3145)
@@ -438,7 +438,7 @@
// popup offset
this.popupOffset = {dx: (isNaN(this.params.horizontalOffset) ? 0 :
parseInt(this.params.horizontalOffset,10)), dy: (isNaN(this.params.verticalOffset) ? 0 :
parseInt(this.params.verticalOffset,10))};
- this.currentDate = this.params.currentDate ? this.params.currentDate : new Date();
+ this.currentDate = this.params.currentDate ? this.params.currentDate :
(this.params.selectedDate ? this.params.selectedDate : new Date());
this.currentDate.setDate(1);
this.selectedDate = this.params.selectedDate;
@@ -1238,17 +1238,20 @@
// fire user event
var flag = true;
+ var isDateChanged = false;
if ( (oldSelectedDate - newSelectedDate) && (oldSelectedDate!=null ||
newSelectedDate!=null) )
{
+ isDateChanged = true
flag = this.invokeEvent("dateselect", eventData.element, eventData.event,
date)
}
if (flag)
- {
+ {
+ var field = $(this.INPUT_DATE_ID);
this.selectedDate = newSelectedDate;
if (this.selectedDate!=null)
{
- $(this.INPUT_DATE_ID).value=this.getSelectedDateString(this.params.datePattern);
+ field.value=this.getSelectedDateString(this.params.datePattern);
var d = new Date(this.selectedDate);
if (d.getMonth()==this.currentDate.getMonth() &&
d.getFullYear()==this.currentDate.getFullYear())
@@ -1274,7 +1277,7 @@
else
{
this.selectedDate = null;
- $(this.INPUT_DATE_ID).value = "";
+ field.value = "";
if (this.selectedDateElement)
{
Element.removeClassName(this.selectedDateElement,
"rich-calendar-select");
@@ -1291,6 +1294,12 @@
}
this.today(noUpdate, true);
}
+
+ // call user event
+ if (isDateChanged)
+ {
+ this.invokeEvent("dateselected", eventData.element, eventData.event,
this.selectedDate);
+ }
}
return flag;
@@ -1311,6 +1320,7 @@
this.renderHeader();
this.renderFooter();
this.doCollapse();
+ this.invokeEvent("dateselected", null, null, null);
}
},
Modified: trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-09-27
14:18:56 UTC (rev 3144)
+++ trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-09-27
15:38:31 UTC (rev 3145)
@@ -53,6 +53,7 @@
firstWeekDay: #{this:getFirstWeekDay(context, component)},
minDaysInFirstWeek: #{this:getMinDaysInFirstWeek(context, component)}
+ <f:call name="writeEventHandlerFunction"><f:parameter
value="ondateselected" /></f:call>
<f:call name="writeEventHandlerFunction"><f:parameter
value="ondateselect" /></f:call>
<f:call name="writeEventHandlerFunction"><f:parameter
value="ondatemouseover" /></f:call>
<f:call name="writeEventHandlerFunction"><f:parameter
value="ondatemouseout" /></f:call>