Author: pyaschenko
Date: 2007-07-26 12:41:30 -0400 (Thu, 26 Jul 2007)
New Revision: 1872
Modified:
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js
trunk/sandbox/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
Modified:
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js
===================================================================
---
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js 2007-07-26
16:21:22 UTC (rev 1871)
+++
trunk/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js 2007-07-26
16:41:30 UTC (rev 1872)
@@ -156,3 +156,5 @@
element = element.parentNode;
}
}
+
+Richfaces.browser={isIE6: /MSIE\s*[6][\d,\.]+;/.test(navigator.userAgent)};
\ No newline at end of file
Modified: trunk/sandbox/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
===================================================================
--- trunk/sandbox/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-07-26
16:21:22 UTC (rev 1871)
+++ trunk/sandbox/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-07-26
16:41:30 UTC (rev 1872)
@@ -84,6 +84,7 @@
<f:selectItem itemLabel="bottom-left"
itemValue="bottom-left"/>
<f:selectItem itemLabel="top-right"
itemValue="top-right"/>
<f:selectItem itemLabel="top-left"
itemValue="top-left"/>
+ <f:selectItem itemLabel="auto" itemValue="auto"/>
</h:selectOneRadio>
<h:commandButton id="calendarPopup" type="button"
value="popup"
onclick="$(this.form.id+':calendar').component.doSwitch();"/>
Modified:
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
---
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-07-26
16:21:22 UTC (rev 1871)
+++
trunk/sandbox/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-07-26
16:41:30 UTC (rev 1872)
@@ -3,15 +3,16 @@
}
if (!Richfaces) Richfaces={};
-Richfaces.Calendar={};
+Richfaces.Calendar={};
Richfaces.Calendar.setElementPosition = function(element, baseElement, jointPoint,
direction, offset)
{
// parameters:
// jointPoint: {x:,y:} or
('left-top','right-top','left-bottom','right-bottom')
// direction:
('left-top','right-top','left-bottom','right-bottom',
'auto')
- var elementDim = {width: element.getWidth(), height: element.getHeight()};
- var baseElementDim = {width: baseElement.getWidth(), height: baseElement.getHeight()};
+ var elementDim = Richfaces.Calendar.getOffsetDimensions(element);
+ var baseElementDim = Richfaces.Calendar.getOffsetDimensions(baseElement);
+
var windowRect = Richfaces.Calendar.getWindowViewport();
var baseOffset = Position.cumulativeOffset(baseElement);
@@ -90,6 +91,30 @@
element.style.top = oy + 'px';
}
+Richfaces.Calendar.getOffsetDimensions = function(element) {
+ // from prototype 1.5.0 // Pavel Yascenko
+ element = $(element);
+ var display = $(element).getStyle('display');
+ if (display != 'none' && display != null) // Safari bug
+ return {width: element.offsetWidth, height: element.offsetHeight};
+
+ // All *Width and *Height properties give 0 on elements with display none,
+ // so enable the element temporarily
+ var els = element.style;
+ var originalVisibility = els.visibility;
+ var originalPosition = els.position;
+ var originalDisplay = els.display;
+ els.visibility = 'hidden';
+ els.position = 'absolute';
+ els.display = 'block';
+ var originalWidth = element.offsetWidth; // was element.clientWidth // Pavel
Yascenko
+ var originalHeight = element.offsetHeight; // was element.clientHeight // Pavel
Yascenko
+ els.display = originalDisplay;
+ els.position = originalPosition;
+ els.visibility = originalVisibility;
+ return {width: originalWidth, height: originalHeight};
+}
+
Richfaces.Calendar.checkCollision = function(elementRect, windowRect, windowOffset)
{
if (elementRect.left >= windowRect.left &&
@@ -327,12 +352,15 @@
this.POPUP_ID = this.id+'Popup';
this.POPUP_BUTTON_ID = this.id+'PopupButton';
this.POPUP_INPUT_ID = this.id+'PopupInput';
+ this.IFRAME_ID = this.id+'IFrame';
this.firstDateIndex = 0;
this.daysData = {startDate:null, days:[]};
this.days = [];
+ var obj=$(id);
+
var htmlTextHeader = '<input id="'+this.id+'InputSelectedDate"
name="'+this.id+'InputSelectedDate" type="hidden"
style="display:none"
value="'+this.getSelectedDateString(this.params.datePattern)+'"/>\n'
+
'<input id="'+this.id+'InputCurrentDate"
name="'+this.id+'InputCurrentDate" type="hidden"
style="display:none"
value="'+this.getCurrentDate().format("MM/y")+'"/>\n'
+
'<table border="0" cellpadding="0"
cellspacing="0" class="calendar_exterior"><tbody>\n';
@@ -342,6 +370,7 @@
var htmlControlsHeader = '<tr><td colspan="'+colspan+'"
id="'+this.id+'Header"></td></tr>';
var htmlControlsFooter = '<tr><td colspan="'+colspan+'"
id="'+this.id+'Footer"></td></tr>';
var htmlTextFooter = '</tbody></table>\n'
+ var htmlTextIFrame = '';
this.isVisible = true;
//if (this.params.popup==true)
@@ -355,6 +384,11 @@
//e.style.left="0px";
//e.style.top="0px";
this.isVisible = false;
+ //if (Richfaces.browser.isIE6)
+ {
+ new Insertion.Before(obj,'<iframe src="javascript:\'\'"
frameborder="0" scrolling="no" id="' + this.IFRAME_ID +
'"' +
+ 'style="display:none; position: absolute; width: 1px; height: 1px;
background-color:white;">'+'</iframe>');
+ }
}
}
@@ -407,10 +441,9 @@
}
// set content
- var obj=$(id);
obj.component = this;
obj.richfacesComponent="richfaces:calendar";
- obj.innerHTML =
htmlTextHeader+htmlHeaderOptional+htmlControlsHeader+htmlTextWeekDayBar+htmlTextWeek+htmlControlsFooter+htmlFooterOptional+htmlTextFooter;
+ obj.innerHTML =
htmlTextIFrame+htmlTextHeader+htmlHeaderOptional+htmlControlsHeader+htmlTextWeekDayBar+htmlTextWeek+htmlControlsFooter+htmlFooterOptional+htmlTextFooter;
this.submitFunction = this.params.submitFunction.bind(this);
this.prepareEvents();
@@ -419,6 +452,7 @@
doCollapse: function() {
if (/*!this.params.popup || */!this.isVisible) return;
+ Element.hide(this.IFRAME_ID);
Element.hide(this.id);
this.isVisible = false;
},
@@ -428,10 +462,18 @@
var base = $(this.POPUP_ID);
var e = $(this.id);
+ var iframe = $(this.IFRAME_ID);
+
+ Richfaces.Calendar.setElementPosition(e, base, this.params.jointPoint,
this.params.direction);
+ iframe.style.left = e.style.left;
+ iframe.style.top = e.style.top;
+ var edim = Richfaces.Calendar.getOffsetDimensions(e);
+ iframe.style.width = edim.width+'px';
+ iframe.style.height = edim.height+'px';
+
+ Element.show(iframe);
+ Element.show(e);
- Richfaces.Calendar.setElementPosition(e, base, this.params.jointPoint,
"");//this.params.direction);
-
- Element.show(this.id);
this.isVisible = true;
},