[richfaces-svn-commits] JBoss Rich Faces SVN: r2353 - in trunk/ui/calendar/src/main: resources/org/richfaces/renderkit/html/scripts and 1 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Mon Aug 20 13:10:24 EDT 2007
Author: pyaschenko
Date: 2007-08-20 13:10:24 -0400 (Mon, 20 Aug 2007)
New Revision: 2353
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
trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
Log:
RF-634 - fixed
added doCollapse function call when user resets selected date
fixed navigation bug
fixed wrong positioning in firefox
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 2007-08-20 17:07:10 UTC (rev 2352)
+++ trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss 2007-08-20 17:10:24 UTC (rev 2353)
@@ -41,7 +41,6 @@
}
.calendar_month{
- border-bottom : 1px solid;
vertical-align : middle;
text-align : center;
}
@@ -140,7 +139,6 @@
</u:selector>
<u:selector name=".calendar_month">
- <u:style name="border-bottom-color" skin="panelBorderColor"/>
<u:style name="background-color" skin="headerBackgroundColor"/>
<u:style name="font-size" skin="headerSizeFont"/>
<u:style name="font-family" skin="headerFamilyFont"/>
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-20 17:07:10 UTC (rev 2352)
+++ trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-08-20 17:10:24 UTC (rev 2353)
@@ -2,21 +2,36 @@
window.LOG = {warn:function(){}};
}
+if(typeof Effect == 'undefined')
+ throw("calendar.js requires including script.aculo.us' effects.js library");
+
if (!Richfaces) Richfaces={};
Richfaces.Calendar={};
Richfaces.Calendar.setElementPosition = function(element, baseElement, jointPoint, direction, offset)
{
// parameters:
+ // baseElement: Dom element or {left:, top:, width:, height:};
// jointPoint: {x:,y:} or ('top-left','top-right','bottom'-left,'bottom-right')
// direction: ('top-left','top-right','bottom'-left,'bottom-right', 'auto')
// offset: {x:,y:}
var elementDim = Richfaces.Calendar.getOffsetDimensions(element);
- var baseElementDim = Richfaces.Calendar.getOffsetDimensions(baseElement);
+ var baseElementDim;
+ var baseOffset;
+
+ if (baseElement.left)
+ {
+ baseElementDim = {width: baseElement.width, height: baseElement.height};
+ baseOffset = [baseElement.left, baseElement.top];
+ } else
+ {
+ baseElementDim = Richfaces.Calendar.getOffsetDimensions(baseElement);
+ baseOffset = Position.cumulativeOffset(baseElement);
+ }
+
var windowRect = Richfaces.Calendar.getWindowViewport();
- var baseOffset = Position.cumulativeOffset(baseElement);
// jointPoint
var ox=baseOffset[0];
@@ -410,6 +425,8 @@
this.daysData = {startDate:null, days:[]};
this.days = [];
+ this.todayCellId = null;
+ this.todayCellColor = "";
var obj=$(id);
@@ -516,13 +533,15 @@
doExpand: function() {
if (!this.params.popup || this.isVisible) return;
- var field = $(this.INPUT_DATE_ID);
- if (field && field.value!=undefined)
+ var base = $(this.POPUP_ID)
+ var baseInput = base.firstChild;
+ var baseButton = baseInput.nextSibling;
+
+ if (baseInput && baseInput.value!=undefined)
{
- this.selectDate(field.value, true);
+ this.selectDate(baseInput.value, true);
}
- var base = $(this.POPUP_ID);
var e = $(this.id);
var iframe = $(this.IFRAME_ID);
@@ -531,8 +550,16 @@
/*this.setPopupEvents(e);
this.setPopupEvents(base);*/
+
+ //rect calculation
+ var offsetBase = Position.cumulativeOffset(base);
+ var offsetDimBase = Richfaces.Calendar.getOffsetDimensions(base);
+ var offsetDimButton = Richfaces.Calendar.getOffsetDimensions(baseButton);
+ var offsetDimInput = Richfaces.Calendar.getOffsetDimensions(baseInput);
+ var o = {left: offsetBase[0], top: offsetBase[1],
+ width: offsetDimBase.width, height: (offsetDimButton.height>offsetDimInput.height ? offsetDimButton.height : offsetDimInput.height)};
- Richfaces.Calendar.setElementPosition(e, base, this.params.jointPoint, this.params.direction);
+ Richfaces.Calendar.setElementPosition(e, o, this.params.jointPoint, this.params.direction);
if (Richfaces.browser.isIE6)
{
iframe.style.left = e.style.left;
@@ -851,7 +878,18 @@
var e;
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;
+ }
+
//var _d=new Date();
if (this.selectedDateElement) {
@@ -902,7 +940,17 @@
}
// TODO make some optimization with calendar_current class
- if (todayflag && dataobj._month==0 && dataobj.day==todaydate) e.add("calendar_current"); else e.remove("calendar_current");
+ if (todayflag && dataobj._month==0 && dataobj.day==todaydate)
+ {
+ this.todayCellId = element.id;
+ this.todayCellColor = Element.getStyle(element, 'background-color').parseColor();
+ e.add("calendar_current");
+ }
+ else
+ {
+ e.remove("calendar_current");
+ }
+
if (selectedflag && dataobj._month==0 && dataobj.day==selecteddate) {
this.selectedDateElement = element;
e.add("Selecteddayclass");
@@ -999,33 +1047,52 @@
this.currentDate = new Date(nowyear, nowmonth, 1);
}
- if (updateflag) if (noUpdate) this.render; else this.onUpdate();
+ if (updateflag)
+ {
+ if (noUpdate) this.render(); else this.onUpdate();
+ }
+ else
+ {
+ // highlight today
+ if (this.isVisible && this.todayCellId)
+ {
+ if (this.highlightEffect)
+ {
+ this.highlightEffect.cancel();
+ this.highlightEffect=null;
+ }
+ var e = $(this.todayCellId);
+ e.style['backgroundColor'] = '';
+ this.highlightEffect = new Effect.Highlight(e, {startcolor: this.todayCellColor, duration:0.3, transition: Effect.Transitions.sinoidal});
+ }
+ }
},
selectDate: function(date, noUpdate) {
+ var oldSelectedDate = this.selectedDate;
if (date)
{
if (typeof date=='string') date = Date.parseDate(date,this.params.datePattern, this.params.monthLabels, this.params.monthLabelsShort);
- if (date!=null)
+ /*if (date!=null)
{
if (this.selectedDate!=null && this.selectedDate.toLocaleDateString()==date.toLocaleDateString()) return;
this.selectedDate = date;
- }
- }
+ }*/
+ this.selectedDate = date;
+ } else this.selectedDate = null;
if (this.selectedDate!=null)
{
var d = new Date(this.selectedDate);
- d.setDate(1);
if (d.getMonth()==this.currentDate.getMonth() && d.getFullYear()==this.currentDate.getFullYear())
{
- if (d.getDate()==this.currentDate.getDate()) return;
// 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();
return;
} else {
// change currentDate and call this.onUpdate();
+ d.setDate(1);
this.currentDate = d;
if (noUpdate) this.render(); else this.onUpdate();
return;
@@ -1034,7 +1101,7 @@
else
{
if (this.selectedDateElement) Element.removeClassName(this.selectedDateElement, "Selecteddayclass");
- this.selectedDate=null;
+ if (oldSelectedDate!=null) if (noUpdate) this.render(); else this.onUpdate();
this.today(noUpdate);
}
},
@@ -1043,7 +1110,9 @@
{
if (!this.selectedDate) return;
this.selectedDate=null;
- if (this.params.popup && this.isVisible) this.render();
+ this.render();
+ if (this.params.popup) Richfaces.createEvent ('click', window.document).fire();
+
$(this.INPUT_DATE_ID).value="";
}
Modified: trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-08-20 17:07:10 UTC (rev 2352)
+++ trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-08-20 17:10:24 UTC (rev 2353)
@@ -9,7 +9,7 @@
baseclass="org.richfaces.renderkit.CalendarRendererBase"
component="org.richfaces.component.UICalendar">
<f:clientid var="clientId" />
- <h:scripts>new org.ajax4jsf.javascript.PrototypeScript(),new org.ajax4jsf.javascript.AjaxScript(),/org/richfaces/renderkit/html/scripts/events.js,/org/richfaces/renderkit/html/scripts/utils.js,/org/richfaces/renderkit/html/scripts/json/json-dom.js,/org/richfaces/renderkit/html/scripts/calendar.js</h:scripts>
+ <h:scripts>new org.ajax4jsf.javascript.PrototypeScript(),new org.ajax4jsf.javascript.AjaxScript(),/org/richfaces/renderkit/html/scripts/events.js,/org/richfaces/renderkit/html/scripts/utils.js,/org/richfaces/renderkit/html/scripts/json/json-dom.js,/org/richfaces/renderkit/html/scripts/scriptaculous/effects.js,/org/richfaces/renderkit/html/scripts/calendar.js</h:scripts>
<h:styles>/org/richfaces/renderkit/html/css/calendar.xcss</h:styles>
<div id="#{clientId}"
@@ -36,16 +36,16 @@
disabled: #{component.disabled},
<f:call name="writeSymbols" />,
firstWeekDay: #{this:getFirstWeekDay(context, component)},
- minDaysInFirstWeek: #{this:getMinDaysInFirstWeek(context, component)},
+ minDaysInFirstWeek: #{this:getMinDaysInFirstWeek(context, component)}
<jsp:scriptlet> /*<![CDATA[*/
if (component.getFacet("optionalHeader")!= null&& component.getFacet("optionalHeader").isRendered()){
/*]]>*/ </jsp:scriptlet>
- headerOptionalMarkup: [new E('b',{},
+ ,headerOptionalMarkup: [new E('b',{},
<jsp:scriptlet> /*<![CDATA[*/
writeMarkupScriptBody(context, component.getFacet("optionalHeader"), false);
/*]]>*/ </jsp:scriptlet>
- )],
+ )]
<jsp:scriptlet> /*<![CDATA[*/
}
/*]]>*/ </jsp:scriptlet>
@@ -53,11 +53,11 @@
<jsp:scriptlet> /*<![CDATA[*/
if (component.getFacet("optionalFooter")!= null&& component.getFacet("optionalFooter").isRendered()){
/*]]>*/ </jsp:scriptlet>
- footerOptionalMarkup: [new E('b',{},
+ ,footerOptionalMarkup: [new E('b',{},
<jsp:scriptlet> /*<![CDATA[*/
writeMarkupScriptBody(context, component.getFacet("optionalFooter"), false);
/*]]>*/ </jsp:scriptlet>
- )],
+ )]
<jsp:scriptlet> /*<![CDATA[*/
}
/*]]>*/ </jsp:scriptlet>
@@ -65,7 +65,7 @@
<jsp:scriptlet>/*<![CDATA[*/
if (component.getChildCount() != 0) {
/*]]>*/</jsp:scriptlet>
- dayListMarkup:
+ ,dayListMarkup:
<jsp:scriptlet>/*<![CDATA[*/
writeMarkupScriptBody(context, component, true);
}
More information about the richfaces-svn-commits
mailing list