PageRenderTime 70ms CodeModel.GetById 67ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/library/platform/DOMSafari.py

http://pyjamas.googlecode.com/
Python | 27 lines | 27 code | 0 blank | 0 comment | 0 complexity | 7e541a699f23884888ab0a717673d90b MD5 | raw file
 1def getAbsoluteLeft(elem):
 2    JS("""
 3    var left = 0;
 4    while (elem) {
 5        left += elem.offsetLeft - elem.scrollLeft;
 6    
 7        var parent = elem.offsetParent;
 8        if (parent && (parent.tagName == 'BODY') && (elem.style.position == 'absolute'))
 9            break;
10        elem = parent;
11    }
12    return left + $doc.body.scrollLeft;
13    """)
14
15def getAbsoluteTop(elem):
16    JS("""
17    var top = 0;
18    while (elem) {
19        top += elem.offsetTop - elem.scrollTop;
20    
21        var parent = elem.offsetParent;
22        if (parent && (parent.tagName == 'BODY') && (elem.style.position == 'absolute'))
23            break;
24        elem = parent;
25    }
26    return top + $doc.body.scrollTop;
27    """)