Author: pyaschenko
Date: 2007-10-11 12:30:26 -0400 (Thu, 11 Oct 2007)
New Revision: 3333
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-1013, RF-1094
Modified: trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
===================================================================
--- trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-10-11 16:25:18
UTC (rev 3332)
+++ trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-10-11 16:30:26
UTC (rev 3333)
@@ -20,6 +20,9 @@
.Selecteddayclass {
background-color: #0087FF;
}
+ .even-day {
+ background-color: #44aa00;
+ }
</style>
</head>
<body>
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-10-11
16:25:18 UTC (rev 3332)
+++
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-10-11
16:30:26 UTC (rev 3333)
@@ -421,7 +421,10 @@
// "scroll" - change current month
// "select" - change current month and select date
+ // isDayEnabled - end-developer JS function
+ // dayStyleClass - end-developer JS function that provide style class for day's
cells.
+
this.id = id;
this.params = parameters;
if (!this.params.showWeekDaysBar) this.params.showWeekDaysBar = true;
@@ -443,6 +446,10 @@
this.selectedDate = this.params.selectedDate;
if (typeof this.params.boundaryDatesMode=="string")
this.params.boundaryDatesMode = this.params.boundaryDatesMode.toLowerCase();
+
+ //
+ if (typeof this.params.isDayEnabled != "function") this.params.isDayEnabled =
function (context) {return true;};
+ if (typeof this.params.dayStyleClass != "function") this.params.dayStyleClass
= function (context) {return "";};
this.todayDate = new Date();
@@ -806,7 +813,7 @@
if (obj)
{
var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
- if (daydata._month==0)
+ if (daydata.enabled && daydata._month==0)
{
var date=new Date(this.currentDate);
date.setDate(daydata.day);
@@ -837,7 +844,7 @@
{
var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
//var date = new Date(this.currentDate.getFullYear(),
this.currentDate.getMonth()+daydata._month, daydata.day);
- if (this.invokeEvent("datemouseover", obj, e, daydata.date))
+ if (this.invokeEvent("datemouseover", obj, e, daydata.date) &&
daydata.enabled)
{
if (daydata._month==0) Element.addClassName(obj,'rich-calendar-hover');
}
@@ -850,7 +857,7 @@
{
var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
//var date = new Date(this.currentDate.getFullYear(),
this.currentDate.getMonth()+daydata._month, daydata.day);
- if (this.invokeEvent("datemouseout", obj, e, daydata.date))
+ if (this.invokeEvent("datemouseout", obj, e, daydata.date) &&
daydata.enabled)
{
if (daydata._month==0) Element.removeClassName(obj,'rich-calendar-hover');
}
@@ -859,16 +866,15 @@
load:function(daysData, isAjaxMode) {
// startDate,
- // days:array[]
+ // daysData:array[]
// {
- // data
- // enabled boolean or function
- // isEnabled function
+ // day
+ // enabled boolean
// text1: 'Meeting...',
// text2: 'Meeting...'
// tooltip
// hasTooltip
- // dayStyleClass
+ // styleClass
// }
if (!$(this.id).component) return;
@@ -1039,7 +1045,7 @@
element = element.nextSibling;
}
- var weekdaycounter = this.params.firstWeekDay;
+ var weekdaycounter = this.params.firstWeekDay;
while (element)
{
@@ -1053,16 +1059,48 @@
dataobj.component = this;
dataobj.isCurrentMonth = (dataobj._month==0);
dataobj.weekDayNumber = weekdaycounter;
+
+ // call user function to get day state
+ if (dataobj.enabled != false) dataobj.enabled = this.params.isDayEnabled(dataobj);
+ // call user function to custom class style
+ if (!dataobj.styleClass) dataobj.customStyleClass =
this.params.dayStyleClass(dataobj);
+ else
+ {
+ var styleclass = this.params.dayStyleClass(dataobj);
+ dataobj.customStyleClass = dataobj.styleClass
+ if (styleclass) dataobj.customStyleClass += " " + styleclass;
+ }
+
+ element.innerHTML = this.evaluateMarkup(this.params.dayListMarkup, dataobj );
if (weekdaycounter==6) weekdaycounter=0; else weekdaycounter++;
- element.innerHTML = this.evaluateMarkup(this.params.dayListMarkup, dataobj );
// class styles
e = Element.classNames(element);
- if (dataobj._month!=0) { e.add('rich-calendar-boundary-dates'); if
(boundaryDatesModeFlag) e.add('rich-calendar-btn'); else
e.remove('rich-calendar-btn');}
+ // remove custom style class
+ if (element.rich && element.rich.customStyleClass)
+ {
+ element.rich.customStyleClass.split('
').each(function(name){e.remove(name);});
+ element.rich.customStyleClass = null;
+ }
+
+ if (dataobj._month!=0)
+ {
+ e.add('rich-calendar-boundary-dates');
+ if (boundaryDatesModeFlag)
+ e.add('rich-calendar-btn');
+ else
+ e.remove('rich-calendar-btn');}
else
{
e.remove('rich-calendar-boundary-dates');
- e.add('rich-calendar-btn');
+ if (dataobj.enabled) e.add('rich-calendar-btn'); else
e.remove('rich-calendar-btn');
+
+ // add custom style class
+ if (dataobj.customStyleClass)
+ {
+ e.add(dataobj.customStyleClass);
+ element.rich = {customStyleClass: dataobj.customStyleClass};
+ }
}
// TODO make some optimization with rich-calendar-today class