Author: pyaschenko
Date: 2007-09-25 09:11:58 -0400 (Tue, 25 Sep 2007)
New Revision: 3094
Modified:
branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
RF-988
Modified:
branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
---
branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-09-25
13:08:58 UTC (rev 3093)
+++
branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-09-25
13:11:58 UTC (rev 3094)
@@ -14,8 +14,10 @@
// 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:}
+ // offset: {dx:,dy:}
+ if (!offset) offset = {dx:0,dy:0};
+
var elementDim = Richfaces.Calendar.getOffsetDimensions(element);
var baseElementDim;
var baseOffset;
@@ -54,14 +56,16 @@
if (direction && (match=direction.toLowerCase().match(re))!=null )
{
var d = direction.toLowerCase().split('-');
- if (match[2]=='left') ox-=elementDim.width;
- if (match[1]=='top') oy-=elementDim.height;
+ if (match[2]=='left') ox-=elementDim.width+offset.dx; else if
(match[2]=='right') ox+=offset.dx;
+ if (match[1]=='top') oy-=elementDim.height+offset.dy; else if
(match[1]=='bottom') oy+=offset.dy;
} else
{
// auto
var theBest = {square:0};
// jointPoint: bottom-right, direction: bottom-left
- var rect = {right: baseOffset[0] + baseElementDim.width, top: baseOffset[1] +
baseElementDim.height};
+ var basex = baseOffset[0]-offset.dx;
+ var basey = baseOffset[1]+offset.dy;
+ var rect = {right: basex + baseElementDim.width, top: basey + baseElementDim.height};
rect.left = rect.right - elementDim.width;
rect.bottom = rect.top + elementDim.height;
ox = rect.left; oy = rect.top;
@@ -70,7 +74,9 @@
{
if (ox>=0 && oy>=0 && theBest.square<s) theBest = {x:ox,
y:oy, square:s};
// jointPoint: top-right, direction: top-left
- rect = {right: baseOffset[0] + baseElementDim.width, bottom: baseOffset[1]};
+ basex = baseOffset[0]-offset.dx;
+ basey = baseOffset[1]-offset.dy;
+ rect = {right: basex + baseElementDim.width, bottom: basey};
rect.left = rect.right - elementDim.width;
rect.top = rect.bottom - elementDim.height;
ox = rect.left; oy = rect.top;
@@ -79,7 +85,9 @@
{
if (ox>=0 && oy>=0 && theBest.square<s) theBest = {x:ox,
y:oy, square:s};
// jointPoint: bottom-left, direction: bottom-right
- rect = {left: baseOffset[0], top: baseOffset[1] + baseElementDim.height};
+ basex = baseOffset[0]+offset.dx;
+ basey = baseOffset[1]+offset.dy;
+ rect = {left: basex, top: basey + baseElementDim.height};
rect.right = rect.left + elementDim.width;
rect.bottom = rect.top + elementDim.height;
ox = rect.left; oy = rect.top;
@@ -88,7 +96,9 @@
{
if (ox>=0 && oy>=0 && theBest.square<s) theBest = {x:ox,
y:oy, square:s};
// jointPoint: top-left, direction: top-right
- rect = {left: baseOffset[0], bottom: baseOffset[1]};
+ basex = baseOffset[0]+offset.dx;
+ basey = baseOffset[1]-offset.dy;
+ rect = {left: basex, bottom: basey};
rect.right = rect.left + elementDim.width;
rect.top = rect.bottom - elementDim.height;
ox = rect.left; oy = rect.top;
@@ -114,9 +124,9 @@
if (element.offsetParent && element.offsetParent!=document.body)
{
- var offset=Position.cumulativeOffset(element.offsetParent);
- ox -= offset[0];
- oy -= offset[1];
+ var parentOffset=Position.cumulativeOffset(element.offsetParent);
+ ox -= parentOffset[0];
+ oy -= parentOffset[1];
}
els.display = originalDisplay;
@@ -425,6 +435,9 @@
if (!this.params.headerMarkup) this.params.headerMarkup = CalendarView.header;
if (!this.params.footerMarkup) this.params.footerMarkup = CalendarView.footer;
+ // popup offset
+ this.popupOffset = {dx: (isNaN(this.params.horizontalOffset) ? 0 :
parseInt(this.params.horizontalOffset,10)), dy: (isNaN(this.params.verticalOffset) ? 0 :
parseInt(this.params.verticalOffset,10))};
+
this.currentDate = this.params.currentDate ? this.params.currentDate : new Date();
this.currentDate.setDate(1);
this.selectedDate = this.params.selectedDate;
@@ -618,7 +631,7 @@
width: offsetDimBase.width,
height: (offsetDimInput && offsetDimInput.height>offsetDimButton.height
? offsetDimInput.height : offsetDimButton.height)};
- Richfaces.Calendar.setElementPosition(element, o, this.params.jointPoint,
this.params.direction);
+ Richfaces.Calendar.setElementPosition(element, o, this.params.jointPoint,
this.params.direction, this.popupOffset);
if (Richfaces.browser.isIE6)
{