Author: pyaschenko
Date: 2007-08-29 12:01:47 -0400 (Wed, 29 Aug 2007)
New Revision: 2585
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-761 fixed
RF-685 fixed
RF-725 partial fix (ondateselect)
Modified: trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
===================================================================
--- trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-08-29 15:59:36
UTC (rev 2584)
+++ trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-08-29 16:01:47
UTC (rev 2585)
@@ -35,6 +35,7 @@
<br />
<br />
<calendar:calendar
+ ondateselect=""
id="calendar"
data="#{calendarDataModel}"
locale="#{calendarBean.locale}"
Modified: trunk/ui/calendar/src/main/config/component/calendar.xml
===================================================================
--- trunk/ui/calendar/src/main/config/component/calendar.xml 2007-08-29 15:59:36 UTC (rev
2584)
+++ trunk/ui/calendar/src/main/config/component/calendar.xml 2007-08-29 16:01:47 UTC (rev
2585)
@@ -323,35 +323,49 @@
</property>
<property>
- <name>onclick</name>
+ <name>ondateselect</name>
<classname>java.lang.String</classname>
<description>
- onClick event handler
+ onDateSelect event handler
</description>
</property>
<property>
- <name>onfocus</name>
+ <name>oncurrentdatechange</name>
<classname>java.lang.String</classname>
<description>
- onFocus event handler
+ onCurrentDateChange event handler
</description>
- </property>
+ </property>
<property>
- <name>onBlur</name>
+ <name>onexpand</name>
<classname>java.lang.String</classname>
<description>
- onBlur event handler
+ onExpand event handler
</description>
</property>
<property>
- <name>onChange</name>
+ <name>oncollapse</name>
<classname>java.lang.String</classname>
<description>
- onChange event handler
+ onCollapse event handler
</description>
</property>
-
<property>
+ <name>ondatemouseover</name>
+ <classname>java.lang.String</classname>
+ <description>
+ onDateMouseOver event handler
+ </description>
+ </property>
+ <property>
+ <name>ondatemouseout</name>
+ <classname>java.lang.String</classname>
+ <description>
+ onDateMouseOut event handler
+ </description>
+ </property>
+
+ <property>
<name>oninputchange</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-08-29
15:59:36 UTC (rev 2584)
+++
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-08-29
16:01:47 UTC (rev 2585)
@@ -451,7 +451,7 @@
var obj=$(id);
var htmlTextHeader = (!this.params.popup ? '<input
id="'+this.INPUT_DATE_ID+'"
name="'+this.INPUT_DATE_ID+'" type="hidden"
style="display:none"
value="'+this.getSelectedDateString(this.params.datePattern)+'"/>\n'
: '') +
- '<input id="'+this.id+'InputCurrentDate"
name="'+this.id+'InputCurrentDate" type="hidden"
style="display:none"
value="'+this.getCurrentDate().format("MM/y")+'"/>\n'
+
+ '<input id="'+this.id+'InputCurrentDate"
name="'+this.id+'InputCurrentDate" type="hidden"
style="display:none"
value="'+this.getCurrentDate().format("MM/yyyy")+'"/>\n'
+
'<table border="0" cellpadding="0"
cellspacing="0"
class="rich-calendar-exterior"><tbody>\n';
var colspan = (this.params.showWeeksBar ? "8" : "7");
var htmlHeaderOptional = (this.params.headerOptionalMarkup) ? '<tr><td
class="rich-calendar-header-optional" colspan="'+colspan+'"
id="'+this.id+'HeaderOptional"></td></tr>' :
'';
@@ -726,6 +726,43 @@
Event.stopObserving(obj, "mouseout", this.eventCellOnMouseOut, false);
},
+ invokeEvent: function(eventName, event, date) {
+ var eventScript = this.params['on'+eventName];
+ var result = true;
+
+ if (eventScript)
+ {
+ var props = {};
+ if (date) props.date = date;
+ var eventObj;
+
+ if (event)
+ {
+ eventObj = event;
+ }
+ else if( document.createEventObject )
+ {
+ eventObj = document.createEventObject();
+ }
+ else if( document.createEvent )
+ {
+ eventObj = document.createEvent();
+ eventObj.initEvent( e, true, false );
+ }
+
+ Object.extend(eventObj, props);
+
+ try
+ {
+ result = new Function("event", eventScript).call(this, eventObj);
+ }
+ catch (e) { LOG.warn("Exception: "+e.Message + "\n[on"+eventName +
"]"); }
+
+ }
+
+ return result;
+ },
+
eventCellOnClick: function (e) {
var obj = Event.findElementByAttr(e, "TD", "id",
this.DATE_ELEMENT_ID, true);
if (obj)
@@ -733,28 +770,37 @@
var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
if (daydata._month==0)
{
- this.selectedDate=new Date(this.currentDate);
- this.selectedDate.setDate(obj.data);
- if (this.selectedDateElement) Element.removeClassName(this.selectedDateElement,
"rich-calendar-select");
- this.selectedDateElement = obj;
- Element.addClassName(obj, "rich-calendar-select");
+ var date=new Date(this.currentDate);
+ date.setDate(obj.data);
- $(this.INPUT_DATE_ID).value=this.getSelectedDateString(this.params.datePattern);
- this.renderHeader();
- this.renderFooter();
-
- // popup mode
- this.doCollapse();
+ if (this.invokeEvent("dateselect", e, date))
+ {
+ this.selectedDate=date;
+ if (this.selectedDateElement) Element.removeClassName(this.selectedDateElement,
"rich-calendar-select");
+ this.selectedDateElement = obj;
+ Element.addClassName(obj, "rich-calendar-select");
+
+ $(this.INPUT_DATE_ID).value=this.getSelectedDateString(this.params.datePattern);
+ this.renderHeader();
+ this.renderFooter();
+
+ // popup mode
+ this.doCollapse();
+ }
} else {
if (this.params.boundaryDatesMode == "scroll")
if (daydata._month==-1) this.prevMonth(); else this.nextMonth();
else if (this.params.boundaryDatesMode == "select")
{
- this.selectDate(new Date(this.currentDate.getFullYear(),
this.currentDate.getMonth()+daydata._month, daydata.day), true);
- $(this.INPUT_DATE_ID).value=this.getSelectedDateString(this.params.datePattern);
- // popup mode
- this.doCollapse();
+ var date = new Date(this.currentDate.getFullYear(),
this.currentDate.getMonth()+daydata._month, daydata.day);
+ if (this.invokeEvent("dateselect", e, date))
+ {
+ this.selectDate(date, true);
+ $(this.INPUT_DATE_ID).value=this.getSelectedDateString(this.params.datePattern);
+ // popup mode
+ this.doCollapse();
+ }
}
}
}
@@ -1032,7 +1078,7 @@
onUpdate: function()
{
- var formattedDate = this.getCurrentDate().format("MM/y");
+ var formattedDate = this.getCurrentDate().format("MM/yyyy");
$(this.id+'InputCurrentDate').value=formattedDate;
if (this.submitFunction)
@@ -1121,9 +1167,12 @@
var d = new Date(this.selectedDate);
if (d.getMonth()==this.currentDate.getMonth() &&
d.getFullYear()==this.currentDate.getFullYear())
{
- // find cell and call onklick event
- var e = $(this.DATE_ELEMENT_ID+(this.firstDateIndex +
this.selectedDate.getDate()-1));
- if (e) Richfaces.createEvent ('click', e).fire();
+ if (oldSelectedDate.getDate()!=d.getDate())
+ {
+ // find cell and call onclick event
+ var e = $(this.DATE_ELEMENT_ID+(this.firstDateIndex +
this.selectedDate.getDate()-1));
+ if (e) Richfaces.createEvent ('click', e).fire();
+ }
return;
} else {
// change currentDate and call this.onUpdate();
@@ -1191,7 +1240,7 @@
CalendarView.previousYearControl = CalendarView.getControl("<<",
"prevYear");
CalendarView.nextMonthControl = CalendarView.getControl(">",
"nextMonth");
CalendarView.previousMonthControl = CalendarView.getControl("<",
"prevMonth");
-CalendarView.currentMonthControl = function (context) { return
context.calendar.getCurrentDate().format("MMMM, y", context.monthLabels,
context.monthLabelsShort);};
+CalendarView.currentMonthControl = function (context) { return
context.calendar.getCurrentDate().format("MMMM, yyyy", context.monthLabels,
context.monthLabelsShort);};
CalendarView.todayControl = CalendarView.getControl("Today",
"today");
CalendarView.selectedDateControl = function (context) { return
CalendarView.getSelectedDateControl(context.calendar.getSelectedDateString(context.calendar.params.datePattern));};
//CalendarView.resetSelectedDateControl = function (context) { return
(context.calendar.getSelectedDate() ? CalendarView.getControl("x",
"resetSelectedDate") : "");};
Modified: trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-08-29
15:59:36 UTC (rev 2584)
+++ trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-08-29
16:01:47 UTC (rev 2585)
@@ -37,7 +37,8 @@
disabled: #{component.disabled},
<f:call name="writeSymbols" />,
firstWeekDay: #{this:getFirstWeekDay(context, component)},
- minDaysInFirstWeek: #{this:getMinDaysInFirstWeek(context, component)}
+ minDaysInFirstWeek: #{this:getMinDaysInFirstWeek(context, component)},
+ ondateselect: "#{component.attributes['ondateselect']}"
<jsp:scriptlet> /*<![CDATA[*/
if (component.getFacet("optionalHeader")!= null&&
component.getFacet("optionalHeader").isRendered()){