Magento

eCommerce Software for Online Growth

Magento Forum

From setting up your store to managing your products, pages and promotions to generating detailed reports, the Magento User Guide empowers the user to utilize the platform for all of its vast capacity.
Available in eBook and Print formats – Download Now!!!
   
IE hack for calendar.js positioning
 
pollyplummer
Member
 
Avatar
Total Posts:  71
Joined:  2009-01-19
Tulsa, OK
 

Instead of using the date selector in custom options for products, I changed the settings so that it pops up the calendar.  Everything works fine in Firefox and Safari.  However, IE pops the calendar much further up the page from the box where it belongs.  Has anyone else done a CSS hack for IE to fix this?  Is the positioning in the JS?  Any hints would help smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
pollyplummer
Member
 
Avatar
Total Posts:  71
Joined:  2009-01-19
Tulsa, OK
 

Any JavaScript experts know what I need to alter here to make the calendar pop up next to the box in IE?

/*
 * Different ways to find element's absolute position
 */
Calendar.getAbsolutePos = function(element{

    
var res = new Object();
    
res.0res.0;

    
// variant 1 (working best, copy-paste from prototype library)
    
do {
        res
.+= element.offsetLeft || 0;
        
res.+= element.offsetTop  || 0;
        
element element.offsetParent;
        if (
element{
            
if (element.tagName.toUpperCase() == 'BODY') break;
            var 
Calendar.getStyle(element'position');
            if (
!== 'static') break;
        
}
    } 
while (element);

    return 
res;

    
// variant 2 (good solution, but lost in IE8)
    
if (element !== null{
        res
.element.offsetLeft;
        
res.element.offsetTop;

        var 
offsetParent element.offsetParent;
        var 
parentNode element.parentNode;

        while (
offsetParent !== null{
            res
.+= offsetParent.offsetLeft;
            
res.+= offsetParent.offsetTop;

            if (
offsetParent != document.body && offsetParent != document.documentElement{
                res
.-= offsetParent.scrollLeft;
                
res.-= offsetParent.scrollTop;
            
}
            
//next lines are necessary to support FireFox problem with offsetParent
            
if (Calendar.is_gecko{
                
while (offsetParent != parentNode && parentNode !== null{
                    res
.-= parentNode.scrollLeft;
                    
res.-= parentNode.scrollTop;
                    
parentNode parentNode.parentNode;
                
}
            }
            parentNode 
offsetParent.parentNode;
            
offsetParent offsetParent.offsetParent;
        
}
    }
    
return res;

    
// variant 2 (not working)

//    var SL = 0, ST = 0;
//    var is_div = /^div$/i.test(el.tagName);
//    if (is_div && el.scrollLeft)
//        SL = el.scrollLeft;
//    if (is_div && el.scrollTop)
//        ST = el.scrollTop;
//    var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
//    if (el.offsetParent) {
//        var tmp = this.getAbsolutePos(el.offsetParent);
//        r.x += tmp.x;
//        r.y += tmp.y;
//    }
//    return r;
};

 
Magento Community Magento Community
Magento Community
Magento Community
 
Carl_Malone
Jr. Member
 
Total Posts:  5
Joined:  2009-06-04
 

Hi,

nice to see I am not alone with this problem. I solved it this way:

In Calendar.js, around line 1459:

if (Calendar.is_ie{
          
/* old non working
            br.y += document.body.scrollTop;
            br.x += document.body.scrollLeft; */
            
br.+= document.body.document.documentElement.scrollTop;
            
br.+= document.body.document.documentElement.scrollLeft;

Need to test it in older IE versions before 100% sure that it works.

 
Magento Community Magento Community
Magento Community
Magento Community
 
thaddeusmt
Member
 
Avatar
Total Posts:  31
Joined:  2009-02-02
Bozeman, MT
 

Thanks, Carl_Malone!!

Works like a charm, as far as I can tell.

I really needed this too, since the client needed Cal popups in the backend and refuses to use Firefox. smile

 Signature 

---------------------------------------------------
http://www.chilipepperdesign.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
webshop discounter
Sr. Member
 
Total Posts:  227
Joined:  2008-09-23
 

Thanks, Carl_Malone!!

I was looking for this a long time!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Vijay_TDS
Jr. Member
 
Total Posts:  3
Joined:  2009-11-06
 

Thank you...Its magic really working in IE 8

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
© Copyright 2010 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
177728 users|1054 users currently online|277236 forum posts