Author: pyaschenko
Date: 2008-01-09 12:19:35 -0500 (Wed, 09 Jan 2008)
New Revision: 5233
Modified:
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
RF-1717
Modified:
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss
===================================================================
---
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss 2008-01-09
17:09:30 UTC (rev 5232)
+++
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss 2008-01-09
17:19:35 UTC (rev 5233)
@@ -49,6 +49,7 @@
.rich-calendar-month{
vertical-align : middle;
text-align : center;
+ height : 22px;
}
.rich-calendar-days{
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 2008-01-09
17:09:30 UTC (rev 5232)
+++
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2008-01-09
17:19:35 UTC (rev 5233)
@@ -549,6 +549,7 @@
// style - table style
// className - table class
+ //var _d = new Date();
this.id = id;
this.params = parameters;
@@ -649,6 +650,8 @@
var bottomStyleClass;
var htmlTextWeekDayBar='';
var context;
+ var tempStr = "$('"+this.id+"').component.";
+ var eventsStr = 'onclick="'+tempStr+'eventCellOnClick(event,
this);" onmouseover="'+tempStr+'eventCellOnMouseOver(event, this);"
onmouseout="'+tempStr+'eventCellOnMouseOut(event, this);"';
if (this.params.showWeekDaysBar)
{
var htmlTextWeekDayBar = '<tr
id="'+this.params.weekDayBarId+'">';
@@ -674,6 +677,7 @@
// week & weekNumber creation
var htmlTextWeek='';
var p=0;
+ this.dayCellClassName = [];
for (k=1;k<7;k++)
{
@@ -693,15 +697,16 @@
if (i==this.firstWeekendDayNumber || i==this.secondWeekendDayNumber)
styleClass+=" rich-calendar-holly";
if (i==6) styleClass+=" rich-right-cell";
- htmlTextWeek+='<td class="'+styleClass+'"
id="'+this.DATE_ELEMENT_ID+p+'">'+(this.customDayListMarkup ?
'<div class="rich-calendar-cell-div'+(this.params.dayCellClass ? '
'+this.params.dayCellClass : '')+'"></div>' :
'')+'</td>';
+ this.dayCellClassName.push(styleClass);
+ htmlTextWeek+='<td class="'+styleClass+'"
id="'+this.DATE_ELEMENT_ID+p+'"'+
+ eventsStr+
+ '>'+(this.customDayListMarkup ? '<div
class="rich-calendar-cell-div'+(this.params.dayCellClass ? '
'+this.params.dayCellClass : '')+'"></div>' :
'')+'</td>';
p++;
}
htmlTextWeek+='</tr>';
}
- var span=$(this.POPUP_ID);
-
- var obj = span.nextSibling;
+ var obj = $(this.POPUP_ID).nextSibling;
if (this.params.popup && Richfaces.browser.isIE6)
{
do {
@@ -730,14 +735,12 @@
obj.component = this;
obj.richfacesComponent="richfaces:calendar";
+ // memory leaks fix
obj = null;
- span = null;
if(this.params.submitFunction) this.submitFunction =
this.params.submitFunction.bind(this);
this.prepareEvents();
- this.doSetCellEvents=true;
-
// add onclick event handlers to input field and popup button
if (this.params.popup && !this.params.disabled)
{
@@ -749,6 +752,8 @@
}
}
+ //alert(new Date().getTime()-_d.getTime());
+
},
dateEditorSelectYear: function(value)
@@ -1044,10 +1049,6 @@
if (this.isEditorVisible) this.hideEditor();
- /*this.stopTimer();
- this.stopPopupEvents($(this.id));
- this.stopPopupEvents($(this.POPUP_ID));*/
-
var element = $(this.id);
if (this.invokeEvent("collapse", element))
@@ -1061,19 +1062,6 @@
Element.hide(element);
this.isVisible = false;
- /*if (this.floatedToBody && this.parent)
- {
- if (iframe)
- {
- document.body.removeChild(iframe);
- this.parent.appendChild(iframe);
- }
- document.body.removeChild(element);
- this.parent.appendChild(element);
- this.floatedToBody = false;
- this.parent = null;
- }*/
-
}
},
@@ -1090,13 +1078,6 @@
var iframe=null;
if (Richfaces.browser.isIE6) iframe = $(this.IFRAME_ID);
- /*if (!this.floatedToBody) {
- this.parent = element.parentNode;
- if (iframe) document.body.insertBefore(this.parent.removeChild(iframe), null);
- document.body.insertBefore(this.parent.removeChild(element), null);
- this.floatedToBody = true;
- }*/
-
var base = $(this.POPUP_ID)
var baseInput = base.firstChild;
var baseButton = baseInput.nextSibling;
@@ -1106,9 +1087,6 @@
this.selectDate(baseInput.value);
}
- /*this.setPopupEvents(e);
- this.setPopupEvents(base);*/
-
//rect calculation
var offsetBase = Position.cumulativeOffset(baseButton);
@@ -1222,52 +1200,9 @@
},
prepareEvents: function() {
- this.eventCellOnClick = this.eventCellOnClick.bindAsEventListener(this);
- this.eventCellOnMouseOver = this.eventCellOnMouseOver.bindAsEventListener(this);
- this.eventCellOnMouseOut = this.eventCellOnMouseOut.bindAsEventListener(this);
this.eventOnCollapse = this.eventOnCollapse.bindAsEventListener(this);
- //this.eventOnMouseOver = this.eventOnMouseOver.bindAsEventListener(this);
- //this.eventOnMouseOut = this.eventOnMouseOut.bindAsEventListener(this);
},
-/* setPopupEvents: function(obj) {
- Event.observe(obj, "mouseover", this.eventOnMouseOver, false);
- Event.observe(obj, "mouseout", this.eventOnMouseOut, false);
- },
-
- stopPopupEvents: function(obj) {
- Event.stopObserving(obj, "mouseover", this.eventOnMouseOver, false);
- Event.stopObserving(obj, "mouseout", this.eventOnMouseOut, false);
- },
- *
- stopTimer: function()
- {
- if (this.popupIntervalId!=null)
- {
- clearTimeout(this.popupIntervalId);
- this.popupIntervalId=null;
- }
- },
-
- eventOnMouseOver: function(e) {
- this.stopTimer();
- },
-
- eventOnMouseOut: function(e) {
- if (this.popupIntervalId==null) this.popupIntervalId =
setTimeout('$("'+this.id+'").component.doCollapse()',400);
- },*/
-
- setCellEvents: function(obj) {
- Event.observe(obj, "click", this.eventCellOnClick, false);
- Event.observe(obj, "mouseover", this.eventCellOnMouseOver, false);
- Event.observe(obj, "mouseout", this.eventCellOnMouseOut, false);
- },
- stopCellEvents: function(obj) {
- Event.stopObserving(obj, "click", this.eventCellOnClick, false);
- Event.stopObserving(obj, "mouseover", this.eventCellOnMouseOver, false);
- Event.stopObserving(obj, "mouseout", this.eventCellOnMouseOut, false);
- },
-
invokeEvent: function(eventName, element, event, date) {
var eventFunction = this.params['on'+eventName];
var result;
@@ -1306,59 +1241,44 @@
return result;
},
- eventCellOnClick: function (e) {
- var obj = Event.findElementByAttr(e, "TD", "id",
this.DATE_ELEMENT_ID, true);
- if (obj)
+ eventCellOnClick: function (e, obj) {
+ var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
+ if (daydata.enabled && daydata._month==0)
{
- var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
- if (daydata.enabled && daydata._month==0)
+ var date=new Date(this.currentDate);
+ date.setDate(daydata.day);
+
+ if (this.selectDate(date,true) && !this.showApplyButton)
{
- var date=new Date(this.currentDate);
- date.setDate(daydata.day);
+ this.doCollapse();
+ }
- if (this.selectDate(date,true) && !this.showApplyButton)
+ } else {
+ if (this.params.boundaryDatesMode == "scroll")
+ if (daydata._month==-1) this.prevMonth(); else this.nextMonth();
+ else if (this.params.boundaryDatesMode == "select")
+ {
+ if (this.selectDate(daydata.date) && !this.showApplyButton)
{
- this.doCollapse();
+ this.doCollapse();
}
-
- } else {
- if (this.params.boundaryDatesMode == "scroll")
- if (daydata._month==-1) this.prevMonth(); else this.nextMonth();
- else if (this.params.boundaryDatesMode == "select")
- {
- //var date = new Date(this.currentDate.getFullYear(),
this.currentDate.getMonth()+daydata._month, daydata.day);
- if (this.selectDate(daydata.date) && !this.showApplyButton)
- {
- this.doCollapse();
- }
- }
}
}
},
- eventCellOnMouseOver: function (e) {
- var obj = Event.findElementByAttr(e, "TD", "id",
this.DATE_ELEMENT_ID, true);
- if (obj)
+ eventCellOnMouseOver: function (e, obj) {
+ var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
+ if (this.invokeEvent("datemouseover", obj, e, daydata.date) &&
daydata.enabled)
{
- 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) &&
daydata.enabled)
- {
- if (daydata._month==0 && obj.id!=this.selectedDateCellId &&
obj.id!=this.todayCellId) Element.addClassName(obj,'rich-calendar-hover');
- }
+ if (daydata._month==0 && obj.id!=this.selectedDateCellId &&
obj.id!=this.todayCellId) Element.addClassName(obj,'rich-calendar-hover');
}
},
- eventCellOnMouseOut: function (e) {
- var obj = Event.findElementByAttr(e, "TD", "id",
this.DATE_ELEMENT_ID, true);
- if (obj)
+ eventCellOnMouseOut: function (e, obj) {
+ var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
+ if (this.invokeEvent("datemouseout", obj, e, daydata.date) &&
daydata.enabled)
{
- 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) &&
daydata.enabled)
- {
- if (daydata._month==0 && obj.id!=this.selectedDateCellId &&
obj.id!=this.todayCellId) Element.removeClassName(obj,'rich-calendar-hover');
- }
+ if (daydata._month==0 && obj.id!=this.selectedDateCellId &&
obj.id!=this.todayCellId) Element.removeClassName(obj,'rich-calendar-hover');
}
},
@@ -1375,7 +1295,7 @@
// styleClass
// }
- if (!$(this.id).component) return;
+ //if (!$(this.id).component) return;
if (daysData) {
this.daysData = this.indexData(daysData, isAjaxMode);
@@ -1456,7 +1376,7 @@
},
render:function() {
-
+ //var _d=new Date();
this.todayDate = new Date();
var currentYear = this.getCurrentYear();
@@ -1546,11 +1466,10 @@
var boundaryDatesModeFlag = (this.params.boundaryDatesMode == "scroll" ||
this.params.boundaryDatesMode == "select");
- this.todayCellId = this.clearEffect(this.todayCellId, this.highlightEffect,
"rich-calendar-today");
- this.selectedDateCellId = this.clearEffect(this.selectedDateCellId,
this.highlightEffect2, "rich-calendar-select", "rich-calendar-btn");
+ this.todayCellId = this.clearEffect(this.todayCellId, this.highlightEffect);
+ this.selectedDateCellId = this.clearEffect(this.selectedDateCellId,
this.highlightEffect2);
//var _d=new Date();
-
var obj = $(this.params.weekNumberBarId+"1");
for (var k=1;k<7;k++)
{
@@ -1581,9 +1500,6 @@
while (element)
{
- // TODO fix start/stop event's calls
- //this.stopCellEvents(element);
-
dataobj.elementId=element.id;
dataobj.date=new Date(currentYear, currentMonth+dataobj._month, dataobj.day);
dataobj.weekNumber = weeknumber;
@@ -1598,7 +1514,7 @@
else
{
var styleclass = this.params.dayStyleClass(dataobj);
- dataobj.customStyleClass = dataobj.styleClass
+ dataobj.customStyleClass = dataobj.styleClass;
if (styleclass) dataobj.customStyleClass += " " + styleclass;
}
@@ -1607,58 +1523,48 @@
if (weekdaycounter==6) weekdaycounter=0; else weekdaycounter++;
- // class styles
- e = Element.classNames(element);
- // remove custom style class
- if (element.rich && element.rich.customStyleClass)
- {
- element.rich.customStyleClass.split('
').each(function(name){e.remove(name);});
- element.rich.customStyleClass = null;
- }
+ var classNames = this.dayCellClassName[p];
+ // class styles
if (dataobj._month!=0)
{
- e.add('rich-calendar-boundary-dates');
+ classNames+=' rich-calendar-boundary-dates';
if (boundaryDatesModeFlag)
- e.add('rich-calendar-btn');
- else
- e.remove('rich-calendar-btn');}
+ {
+ classNames+=' rich-calendar-btn';
+ }
+ }
else
{
- e.remove('rich-calendar-boundary-dates');
- if (dataobj.enabled) e.add('rich-calendar-btn'); else
e.remove('rich-calendar-btn');
+ if (todayflag && dataobj.day==todaydate)
+ {
+ this.todayCellId = element.id;
+ this.todayCellColor = this.getCellBackgroundColor(element);
+ classNames+=" rich-calendar-today";
+ }
+
+ if (selectedflag && dataobj.day==selecteddate)
+ {
+ this.selectedDateCellId = element.id;
+ this.selectedDateCellColor = this.getCellBackgroundColor(element);
+ classNames+=" rich-calendar-select";
+ }
+ else if (dataobj.enabled) classNames+=' rich-calendar-btn';
// add custom style class
if (dataobj.customStyleClass)
{
- e.add(dataobj.customStyleClass);
- element.rich = {customStyleClass: dataobj.customStyleClass};
+ classNames+=' '+dataobj.customStyleClass;
}
}
+ element.className = classNames;
- // TODO make some optimization with rich-calendar-today class
- if (todayflag && dataobj._month==0 && dataobj.day==todaydate)
- {
- this.todayCellId = element.id;
- this.todayCellColor = this.getCellBackgroundColor(element);
- e.add("rich-calendar-today");
- }
-
- if (selectedflag && dataobj._month==0 && dataobj.day==selecteddate)
- {
- this.selectedDateCellId = element.id;
- this.selectedDateCellColor = this.getCellBackgroundColor(element);
- e.remove("rich-calendar-btn");
- e.add("rich-calendar-select");
- }
-
- if (this.doSetCellEvents) this.setCellEvents(element);
p++;
dataobj = this.days[p];
element=element.nextSibling;
}
- obj = obj.nextSibling;
+ obj = obj.nextSibling;
}
//alert(new Date().getTime()-_d.getTime());
@@ -1673,7 +1579,6 @@
element.style.height = "0px";
}
}*/
- this.doSetCellEvents = false;
},
renderHF: function()