diff options
author | Andrew Dolgov <[email protected]> | 2007-08-20 05:57:01 +0100 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2007-08-20 05:57:01 +0100 |
commit | 537625c60ce43a9a12416ffbcbfaad738f5d4682 (patch) | |
tree | 2059f6f1fb341f3b42113c944b731ce09ec751c8 /functions.js | |
parent | 91d64fb808306f4409c4cf8a1405d58f6202a20f (diff) |
piggification updates
Diffstat (limited to 'functions.js')
-rw-r--r-- | functions.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/functions.js b/functions.js index b5b8f7b63..e9c14b63c 100644 --- a/functions.js +++ b/functions.js @@ -1892,3 +1892,32 @@ function openArticleInNewWindow(id) { } } +/* http://textsnippets.com/posts/show/835 */ + +Position.GetWindowSize = function(w) { + w = w ? w : window; + var width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth); + var height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight); + return [width, height] +} + +/* http://textsnippets.com/posts/show/836 */ + +Position.Center = function(element, parent) { + var w, h, pw, ph; + var d = Element.getDimensions(element); + w = d.width; + h = d.height; + Position.prepare(); + if (!parent) { + var ws = Position.GetWindowSize(); + pw = ws[0]; + ph = ws[1]; + } else { + pw = parent.offsetWidth; + ph = parent.offsetHeight; + } + element.style.top = (ph/2) - (h/2) - Position.deltaY + "px"; + element.style.left = (pw/2) - (w/2) - Position.deltaX + "px"; +} + |