Ticket #5067: 5067-patch.4.diff

File 5067-patch.4.diff, 1.6 KB (added by Robert Coup, 17 years ago)

Nicer browser identification & Opera support

  • django/contrib/admin/media/js/core.js

     
    11// Core javascript helper functions
    22
     3// basic browser identification & version
     4var isOpera = (navigator.userAgent.indexOf("Opera")>=0) && parseFloat(navigator.appVersion);
     5var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]);
     6
    37// Cross-browser event handlers.
    48function addEvent(obj, evType, fn) {
    59    if (obj.addEventListener) {
     
    7175    var curleft = 0;
    7276    if (obj.offsetParent) {
    7377        while (obj.offsetParent) {
    74             curleft += obj.offsetLeft;
     78            curleft += obj.offsetLeft - ((isOpera) ? 0 : obj.scrollLeft);
    7579            obj = obj.offsetParent;
    7680        }
     81        // IE offsetParent does not include the top-level
     82        if (isIE && obj.parentElement){
     83            curleft += obj.offsetLeft - obj.scrollLeft;
     84        }
    7785    } else if (obj.x) {
    7886        curleft += obj.x;
    7987    }
     
    8492    var curtop = 0;
    8593    if (obj.offsetParent) {
    8694        while (obj.offsetParent) {
    87             curtop += obj.offsetTop;
     95            curtop += obj.offsetTop - ((isOpera) ? 0 : obj.scrollTop);
    8896            obj = obj.offsetParent;
    8997        }
     98        // IE offsetParent does not include the top-level
     99        if (isIE && obj.parentElement){
     100            curtop += obj.offsetTop - obj.scrollTop;
     101        }
    90102    } else if (obj.y) {
    91103        curtop += obj.y;
    92104    }
Back to Top