diff options
author | Christopher Smith <chris@jalakai.co.uk> | 2011-04-02 03:36:26 +0100 |
---|---|---|
committer | Christopher Smith <chris@jalakai.co.uk> | 2011-04-02 03:36:26 +0100 |
commit | efb973f8a33b893d0a4d46d6b733530833c4ad41 (patch) | |
tree | 9386f06b90a4fc6a5c31183793df17851ca0da26 /lib/scripts/script.js | |
parent | 344763ad4e90e41c8a94b0a69a527ff2d6319ab5 (diff) | |
parent | a3f9f75c2624b73c4a57bf2a346ae71bf6a5fb98 (diff) | |
download | rpg-efb973f8a33b893d0a4d46d6b733530833c4ad41.tar.gz rpg-efb973f8a33b893d0a4d46d6b733530833c4ad41.tar.bz2 |
Merge branch 'master' of git@github.com:splitbrain/dokuwiki
Diffstat (limited to 'lib/scripts/script.js')
-rw-r--r-- | lib/scripts/script.js | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/lib/scripts/script.js b/lib/scripts/script.js index b9b324f96..2cc1246f9 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -114,6 +114,20 @@ function findPosY(object){ } //end findPosY function /** + * Get the computed style of a node. + * + * @link https://acidmartin.wordpress.com/2008/08/26/style-get-any-css-property-value-of-an-object/ + * @link http://svn.dojotoolkit.org/src/dojo/trunk/_base/html.js + */ +function gcs(node){ + if(node.currentStyle){ + return node.currentStyle; + }else{ + return node.ownerDocument.defaultView.getComputedStyle(node, null); + } +} + +/** * Escape special chars in JavaScript * * @author Andreas Gohr <andi@splitbrain.org> @@ -260,10 +274,32 @@ function insitu_popup(target, popup_id) { getElementsByClass('dokuwiki', document.body, 'div')[0].appendChild(fndiv); } + var non_static_parent = fndiv.parentNode; + while (non_static_parent != document && gcs(non_static_parent)['position'] == 'static') { + non_static_parent = non_static_parent.parentNode; + } + + var fixed_target_parent = target; + while (fixed_target_parent != document && gcs(fixed_target_parent)['position'] != 'fixed') { + fixed_target_parent = fixed_target_parent.parentNode; + } + // position the div and make it visible - fndiv.style.position = 'absolute'; - fndiv.style.left = findPosX(target)+'px'; - fndiv.style.top = (findPosY(target)+target.offsetHeight * 1.5) + 'px'; + if (fixed_target_parent != document) { + // the target has position fixed, that means the footnote needs to be fixed, too + fndiv.style.position = 'fixed'; + } else { + fndiv.style.position = 'absolute'; + } + + if (fixed_target_parent != document || non_static_parent == document) { + fndiv.style.left = findPosX(target)+'px'; + fndiv.style.top = (findPosY(target)+target.offsetHeight * 1.5) + 'px'; + } else { + fndiv.style.left = (findPosX(target) - findPosX(non_static_parent)) +'px'; + fndiv.style.top = (findPosY(target)+target.offsetHeight * 1.5 - findPosY(non_static_parent)) + 'px'; + } + fndiv.style.display = ''; return fndiv; } |