]> git.wh0rd.org - tt-rss.git/blame - lib/position.js
remove twitter-specific code
[tt-rss.git] / lib / position.js
CommitLineData
b19d6e6e
AD
1/* http://textsnippets.com/posts/show/835 */
2
3Position.GetWindowSize = function(w) {
4 w = w ? w : window;
5 var width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
6 var height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);
e331188f
AD
7 return [width, height];
8};
b19d6e6e
AD
9
10/* http://textsnippets.com/posts/show/836 */
11
12Position.Center = function(element, parent) {
13 var w, h, pw, ph;
14 var d = Element.getDimensions(element);
15 w = d.width;
16 h = d.height;
17 Position.prepare();
18 if (!parent) {
19 var ws = Position.GetWindowSize();
20 pw = ws[0];
21 ph = ws[1];
22 } else {
23 pw = parent.offsetWidth;
24 ph = parent.offsetHeight;
25 }
26 element.style.top = (ph/2) - (h/2) - Position.deltaY + "px";
27 element.style.left = (pw/2) - (w/2) - Position.deltaX + "px";
e331188f 28};
b19d6e6e
AD
29
30
31