Author: pyaschenko
Date: 2007-12-03 12:05:24 -0500 (Mon, 03 Dec 2007)
New Revision: 4429
Modified:
trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
RF-1391, RF-1478
todayControlMode parameter added - today control button action: "scroll",
"select", "hidden"
Modified: trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
===================================================================
--- trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-12-03 16:38:07
UTC (rev 4428)
+++ trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-12-03 17:05:24
UTC (rev 4429)
@@ -38,7 +38,7 @@
</h:panelGrid>
<br />
<br />
- <calendar:calendar datePattern="#{calendarBean.pattern}"
showApplyButton="#{calendarBean.showApplyButton}"
popup="#{calendarBean.popup}"/>
+ <calendar:calendar
todayControlMode="#{calendarBean.todayControlMode}"
datePattern="#{calendarBean.pattern}"
showApplyButton="#{calendarBean.showApplyButton}"
popup="#{calendarBean.popup}"/>
<calendar:calendar cellWidth="5" cellHeight="5"/>
<calendar:calendar cellWidth="40" cellHeight="40"/>
<calendar:calendar
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-12-03
16:38:07 UTC (rev 4428)
+++
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-12-03
17:05:24 UTC (rev 4429)
@@ -464,6 +464,11 @@
// "inactive" or undefined - no action (default)
// "scroll" - change current month
// "select" - change current month and select date
+ //
+ // todayControlMode - today control onclick action:
+ // "scroll"
+ // "select"
+ // "hidden"
// isDayEnabled - end-developer JS function
// dayStyleClass - end-developer JS function that provide style class for day's
cells.
@@ -509,6 +514,7 @@
this.selectedDate = this.params.selectedDate;
if (typeof this.params.boundaryDatesMode=="string")
this.params.boundaryDatesMode = this.params.boundaryDatesMode.toLowerCase();
+ if (typeof this.params.todayControlMode=="string") this.todayControlMode =
this.params.todayControlMode.toLowerCase();
//
if (typeof this.params.isDayEnabled != "function") this.params.isDayEnabled =
function (context) {return true;};
@@ -1140,6 +1146,12 @@
}
this.render();
+
+ if (typeof this.afterLoad=='function')
+ {
+ this.afterLoad();
+ this.afterLoad=null;
+ }
},
indexData:function(daysData, isAjaxMode) {
@@ -1330,7 +1342,6 @@
while (element)
{
- // TODO rich-calendar-spec class not implemented
// TODO fix start/stop event's calls
this.stopCellEvents(element);
@@ -1493,12 +1504,14 @@
},
today: function(noUpdate, noHighlight) {
+
var now = new Date();
+
var nowyear = now.getFullYear();
var nowmonth = now.getMonth();
var nowdate = now.getDate();
var updateflag = false;
-
+
if (nowdate!=this.todayDate.getDate()) {updateflag=true; this.todayDate = now;}
if (nowyear != this.currentDate.getFullYear() || nowmonth !=
this.currentDate.getMonth() )
@@ -1506,9 +1519,14 @@
updateflag = true;
this.currentDate = new Date(nowyear, nowmonth, 1);
}
+
+ if (this.todayControlMode=='select')
+ {
+ noHighlight=true;
+ }
if (updateflag)
- {
+ {
if (noUpdate) this.render(); else this.onUpdate();
}
else
@@ -1525,7 +1543,28 @@
}
}
}
+
+ // todayControl select mode
+ if (this.todayControlMode=='select')
+ if (updateflag && !noUpdate && this.submitFunction)
+ {
+ this.afterLoad = this.selectToday;
+ }
+ else this.selectToday();
+
},
+
+ selectToday: function()
+ {
+ if (this.todayCellId)
+ {
+ var daydata =
this.days[parseInt($(this.todayCellId).id.substr(this.DATE_ELEMENT_ID.length),10)];
+ if (daydata.enabled && this.selectDate(new Date(),true) &&
!this.showApplyButton)
+ {
+ this.doCollapse();
+ }
+ }
+ },
onHighlightFinish: function (object)
{
@@ -1533,6 +1572,7 @@
},
selectDate: function(date, noUpdate, eventData) {
+
if (!eventData)
{
eventData = {event: null, element: null};
@@ -1554,7 +1594,7 @@
{
newSelectedDate = null;
}
-
+
// fire user event
var flag = true;
var isDateChanged = false;
@@ -1562,15 +1602,15 @@
{
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)
{
- if (!isDateParsed)
+ if (this.timeType && !isDateParsed)
if (oldSelectedDate!=null)
{
this.selectedDate.setHours(oldSelectedDate.getHours());
@@ -1626,7 +1666,11 @@
{
this.renderHF();
}
+
+ var todayControlMode = this.todayControlMode;
+ this.todayControlMode = '';
this.today(noUpdate, true);
+ this.todayControlMode = todayControlMode;
}
// call user event
@@ -1788,7 +1832,7 @@
CalendarView.nextMonthControl = CalendarView.getControl(">",
CalendarView.toolButtonAttributes, "nextMonth");
CalendarView.previousMonthControl = CalendarView.getControl("<",
CalendarView.toolButtonAttributes, "prevMonth");
CalendarView.currentMonthControl = function (context) { return
Richfaces.Calendar.formatDate(context.calendar.getCurrentDate(), "MMMM, yyyy",
context.monthLabels, context.monthLabelsShort);};
-CalendarView.todayControl = CalendarView.getControl("Today",
CalendarView.toolButtonAttributes, "today");
+CalendarView.todayControl = function (context) { return
(context.calendar.todayControlMode!='hidden' ?
CalendarView.getControl("Today", CalendarView.toolButtonAttributes,
"today") : "");};
CalendarView.selectedDateControl = function (context) { return
CalendarView.getSelectedDateControl(context.calendar);};
CalendarView.timeControl = function (context) { return
CalendarView.getTimeControl(context.calendar);};
CalendarView.closeControl = CalendarView.getControl("x",
CalendarView.toolButtonAttributes, "close", "false");