Author: pyaschenko
Date: 2007-10-26 09:44:21 -0400 (Fri, 26 Oct 2007)
New Revision: 3566
Modified:
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
RF-1132
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-26
13:41:35 UTC (rev 3565)
+++
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-10-26
13:44:21 UTC (rev 3566)
@@ -453,8 +453,6 @@
this.todayDate = new Date();
- this.selectedDateCellId = null;
-
this.firstWeekendDayNumber = 6-this.params.firstWeekDay;
this.secondWeekendDayNumber = (this.params.firstWeekDay>0 ?
7-this.params.firstWeekDay : 0);
@@ -476,6 +474,9 @@
this.days = [];
this.todayCellId = null;
this.todayCellColor = "";
+
+ this.selectedDateCellId = null;
+ this.selectedDateCellColor = "";
var obj=$(id);
@@ -922,6 +923,45 @@
return daysData;
},
+ getCellBackgroundColor: function(element)
+ {
+ var result;
+ if (Richfaces.browser.isSafari && this.params.popup &&
!this.isVisible)
+ {
+ // Safari 2.0 fix
+ // if [display:none] Element.getStyle() function returns null;
+ var els = $(this.id).style;
+ var originalVisibility = els.visibility;
+ var originalDisplay = els.display;
+ els.visibility = 'hidden';
+ els.display = '';
+ result = Element.getStyle(element, 'background-color').parseColor();
+ els.display = originalDisplay;
+ els.visibility = originalVisibility;
+ } else
+ {
+ result = Element.getStyle(element, 'background-color').parseColor();
+ }
+
+ return result;
+ },
+
+ clearEffect: function (element_id, effect, className)
+ {
+ if (effect)
+ {
+ effect.cancel();
+ effect=null;
+ }
+ if (element_id)
+ {
+ var e = $(element_id);
+ e.style['backgroundColor'] = '';
+ if (className) Element.removeClassName(e, className);
+ }
+ return null;
+ },
+
render:function() {
this.todayDate = new Date();
@@ -1013,24 +1053,11 @@
var boundaryDatesModeFlag = (this.params.boundaryDatesMode == "scroll" ||
this.params.boundaryDatesMode == "select");
- if (this.highlightEffect)
- {
- this.highlightEffect.cancel();
- this.highlightEffect=null;
- }
- if (this.todayCellId)
- {
- $(this.todayCellId).style['backgroundColor'] = '';
- this.todayCellId = null;
- }
+ this.todayCellId = this.clearEffect(this.todayCellId, this.highlightEffect,
"rich-calendar-today");
+ this.selectedDateCellId = this.clearEffect(this.selectedDateCellId,
this.highlightEffect2, "rich-calendar-select");
//var _d=new Date();
- if (this.selectedDateCellId) {
- Element.classNames(this.selectedDateCellId).remove("rich-calendar-select");
- this.selectedDateCellId = null;
- }
-
for (var k=1;k<7;k++)
{
//
@@ -1118,32 +1145,14 @@
if (todayflag && dataobj._month==0 && dataobj.day==todaydate)
{
this.todayCellId = element.id;
-
- if (Richfaces.browser.isSafari && this.params.popup &&
!this.isVisible)
- {
- // Safari 2.0 fix
- // if [display:none] Element.getStyle() function returns null;
- var els = $(this.id).style;
- var originalVisibility = els.visibility;
- var originalDisplay = els.display;
- els.visibility = 'hidden';
- els.display = '';
- this.todayCellColor = Element.getStyle(element,
'background-color').parseColor();
- els.display = originalDisplay;
- els.visibility = originalVisibility;
- } else
- {
- this.todayCellColor = Element.getStyle(element,
'background-color').parseColor();
- }
+ this.todayCellColor = this.getCellBackgroundColor(element);
e.add("rich-calendar-today");
}
- else
+
+ if (selectedflag && dataobj._month==0 && dataobj.day==selecteddate)
{
- e.remove("rich-calendar-today");
- }
-
- if (selectedflag && dataobj._month==0 && dataobj.day==selecteddate)
{
this.selectedDateCellId = element.id;
+ this.selectedDateCellColor = this.getCellBackgroundColor(element);
e.add("rich-calendar-select");
}
@@ -1261,18 +1270,13 @@
else
{
// highlight today
+
if (this.isVisible && this.todayCellId && !noHighlight)
{
- if (this.highlightEffect)
- {
- this.highlightEffect.cancel();
- this.highlightEffect=null;
- }
- var e = $(this.todayCellId);
- e.style['backgroundColor'] = '';
+ this.clearEffect(this.todayCellId, this.highlightEffect);
if (this.todayCellColor!="transparent")
{
- this.highlightEffect = new Effect.Highlight(e, {startcolor: this.todayCellColor,
duration:0.3, transition: Effect.Transitions.sinoidal,
+ this.highlightEffect = new Effect.Highlight($(this.todayCellId), {startcolor:
this.todayCellColor, duration:0.3, transition: Effect.Transitions.sinoidal,
afterFinish: this.onHighlightFinish});
}
}
@@ -1326,8 +1330,10 @@
{
// find cell and change style class
var e = $(this.DATE_ELEMENT_ID+(this.firstDateIndex +
this.selectedDate.getDate()-1));
- if (this.selectedDateCellId) Element.removeClassName(this.selectedDateCellId,
"rich-calendar-select");
+
+ this.clearEffect(this.selectedDateCellId, this.highlightEffect2,
"rich-calendar-select");
this.selectedDateCellId = e.id;
+ this.selectedDateCellColor = this.getCellBackgroundColor(e);
Element.addClassName(e, "rich-calendar-select");
this.renderHeader();
@@ -1344,9 +1350,11 @@
{
this.selectedDate = null;
field.value = "";
+
+ this.clearEffect(this.selectedDateCellId, this.highlightEffect2,
"rich-calendar-select");
+
if (this.selectedDateCellId)
{
- Element.removeClassName(this.selectedDateCellId, "rich-calendar-select");
this.selectedDateCellId = null;
this.renderHeader();
this.renderFooter();
@@ -1377,12 +1385,10 @@
if (this.invokeEvent("dateselect", null, null, null))
{
this.selectedDate = null;
- $(this.INPUT_DATE_ID).value = "";
- if (this.selectedDateCellId)
- {
- Element.removeClassName(this.selectedDateCellId, "rich-calendar-select");
- this.selectedDateCellId = null;
- }
+ $(this.INPUT_DATE_ID).value = "";
+
+ this.selectedDateCellId = this.clearEffect(this.selectedDateCellId,
this.highlightEffect2, "rich-calendar-select");
+
this.renderHeader();
this.renderFooter();
this.doCollapse();
@@ -1402,7 +1408,15 @@
else
{
// highlight Selected Date
-
+ if (this.isVisible && this.selectedDateCellId)
+ {
+ this.clearEffect(this.selectedDateCellId, this.highlightEffect2);
+ if (this.selectedDateCellColor!="transparent")
+ {
+ this.highlightEffect2 = new Effect.Highlight($(this.selectedDateCellId),
{startcolor: this.selectedDateCellColor, duration:0.3, transition:
Effect.Transitions.sinoidal,
+ afterFinish: this.onHighlightFinish});
+ }
+ }
}
}