From commits-return-3314-apmail-myfaces-commits-archive=myfaces.apache.org@myfaces.apache.org Tue Oct 04 17:15:22 2005 Return-Path: Delivered-To: apmail-myfaces-commits-archive@www.apache.org Received: (qmail 27610 invoked from network); 4 Oct 2005 17:15:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Oct 2005 17:15:22 -0000 Received: (qmail 42695 invoked by uid 500); 4 Oct 2005 17:15:20 -0000 Delivered-To: apmail-myfaces-commits-archive@myfaces.apache.org Received: (qmail 42642 invoked by uid 500); 4 Oct 2005 17:15:20 -0000 Mailing-List: contact commits-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Development" > Delivered-To: mailing list commits@myfaces.apache.org Received: (qmail 42629 invoked by uid 99); 4 Oct 2005 17:15:20 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Oct 2005 10:15:20 -0700 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 04 Oct 2005 10:15:24 -0700 Received: (qmail 27487 invoked by uid 65534); 4 Oct 2005 17:14:59 -0000 Message-ID: <20051004171459.27486.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r294842 - /myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/popcalendar.js Date: Tue, 04 Oct 2005 17:14:58 -0000 To: commits@myfaces.apache.org From: mmarinschek@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: mmarinschek Date: Tue Oct 4 10:14:53 2005 New Revision: 294842 URL: http://svn.apache.org/viewcvs?rev=294842&view=rev Log: fix for MYFACES-635 - thanks to Jack Honeghan-Bates Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/popcalendar.js Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/popcalendar.js URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/popcalendar.js?rev=294842&r1=294841&r2=294842&view=diff ============================================================================== --- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/popcalendar.js (original) +++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/popcalendar.js Tue Oct 4 10:14:53 2005 @@ -45,6 +45,14 @@ objTop += objParent.offsetTop; objParent = objParent.offsetParent; } + + objParent = obj.offsetParent; + + while( objParent.tagName.toUpperCase() != "BODY" ){ + objLeft -= objParent.scrollLeft; + objTop -= objParent.scrollTop; + objParent = objParent.parentNode; + } objHeight = obj.offsetHeight; objWidth = obj.offsetWidth; @@ -563,9 +571,41 @@ leftpos += aTag.offsetLeft; toppos += aTag.offsetTop; } while(aTag.tagName!="BODY"); + + var leftScrollOffset = 0; + var topScrollOffset = 0; + + aTag = ctl; + do { + leftScrollOffset += aTag.scrollLeft; + topScrollOffset += aTag.scrollTop; + aTag = aTag.parentNode; + } while(aTag.tagName!="BODY"); + + var bodyRect = getVisibleBodyRectangle(); + var cal = document.getElementById("calendar"); + var top = ctl.offsetTop + toppos - topScrollOffset + ctl.offsetHeight + 2; + var left = ctl.offsetLeft + leftpos - leftScrollOffset; + + if (left + cal.offsetWidth > bodyRect.right) + { + left = bodyRect.right - cal.offsetWidth; + } + if (top + cal.offsetHeight > bodyRect.bottom) + { + top = bodyRect.bottom - cal.offsetHeight; + } + if (left < bodyRect.left) + { + left = bodyRect.left; + } + if (top < bodyRect.top) + { + top = bodyRect.top; + } - jscalendarCrossobj.left = jscalendarFixedX==-1 ? ctl.offsetLeft + leftpos + "px": jscalendarFixedX; - jscalendarCrossobj.top = jscalendarFixedY==-1 ? ctl.offsetTop + toppos + ctl.offsetHeight + 2 + "px": jscalendarFixedY; + jscalendarCrossobj.left = jscalendarFixedX==-1 ? left + "px": jscalendarFixedX; + jscalendarCrossobj.top = jscalendarFixedY==-1 ? top + "px": jscalendarFixedY; jscalendarConstructCalendar (1, jscalendarMonthSelected, jscalendarYearSelected); jscalendarCrossobj.visibility=(jscalendarDom||jscalendarIe)? "visible" : "show"; @@ -573,6 +613,58 @@ jscalendarHideElement( 'APPLET', document.getElementById("calendar") ); jscalendarBShow = true; +} + +function getVisibleBodyRectangle() +{ + var visibleRect = new Rectangle(); + + if (window.pageYOffset != undefined) + { + //Most non IE + visibleRect.top = window.pageYOffset; + visibleRect.left = window.pageXOffset; + } + else if(document.body && document.body.scrollTop ) + { + //IE 6 strict mode + visibleRect.top = document.body.scrollTop; + visibleRect.left = document.body.scrollLeft; + } + else if(document.documentElement && document.documentElement.scrollTop ) + { + //Older IE + visibleRect.top = document.documentElement.scrollTop; + visibleRect.left = document.documentElement.scrollLeft; + } + + if( window.innerWidth != undefined ) + { + //Most non-IE + visibleRect.right = visibleRect.left + window.innerWidth; + visibleRect.bottom = visibleRect.top + window.innerHeight; + } + else if( document.documentElement && document.documentElement.clientHeight ) + { + //IE 6 strict mode + visibleRect.right = visibleRect.left + document.documentElement.clientWidth; + visibleRect.bottom = visibleRect.top + document.documentElement.clientHeight; + } + else if( document.body && document.body.clientHeight ) + { + //IE 4 compatible + visibleRect.right = visibleRect.left + document.body.clientWidth; + visibleRect.bottom = visibleRect.top + document.body.clientHeight; + } + return visibleRect; +} + +function Rectangle() +{ + this.top = 0; + this.left = 0; + this.bottom = 0; + this.right = 0; } document.onkeypress = function jscalendarHidecal1 () {