PageRenderTime 19ms CodeModel.GetById 12ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/ddoc/candydoc/util.js

http://github.com/baryluk/cords
JavaScript | 41 lines | 31 code | 6 blank | 4 comment | 10 complexity | efa18e9c117dc52987a7581f694ee3d5 MD5 | raw file
 1/* This file is a part of CanDyDOC fileset.
 2   File is written by Victor Nakoryakov and placed into the public domain.
 3
 4   This file is javascript with cross-browser utility functions. */
 5
 6function getLeft(elem)
 7{
 8    var ret = 0;
 9	while (elem.offsetParent)
10	{
11		ret += elem.offsetLeft;
12		elem = elem.offsetParent;
13	}
14
15	return ret;
16}
17
18function getTop(elem)
19{
20    var ret = 0;
21	while (elem.offsetParent)
22	{
23		ret += elem.offsetTop;
24		elem = elem.offsetParent;
25	}
26
27	return ret;
28}
29
30function getWindowHeight()
31{
32    var ret = 0;
33    if (typeof(window.innerHeight) == "number")
34        ret = window.innerHeight;
35    else if (document.documentElement && document.documentElement.clientHeight)
36        ret = document.documentElement.clientHeight;
37    else if (document.body && document.body.clientHeight)
38        ret = document.body.clientHeight;
39    
40    return ret;
41}