diff options
author | Adrian Lang <lang@cosmocode.de> | 2010-03-15 16:57:38 +0100 |
---|---|---|
committer | Adrian Lang <lang@cosmocode.de> | 2010-03-15 17:00:50 +0100 |
commit | fda42deb082e4bdb560818a9c23b96f9312176d5 (patch) | |
tree | 00320dee9b6beee838bcdcdc55cb6dea013c690c /lib/scripts/script.js | |
parent | c7cb395c4ee1339709918b7675e91d3d3b10050d (diff) | |
download | dokuwiki-fda42deb082e4bdb560818a9c23b96f9312176d5.tar.gz dokuwiki-fda42deb082e4bdb560818a9c23b96f9312176d5.zip |
Various JavaScript fixes
* Syntax error fixed
* lock refresh event is now attached to the whole edit form since it bubbles
up and we cannot be sure that the wikitext input exists on all edit forms
* Updated findPos(X|Y)
* Easier and less error-prone way of getting the section edit button in the
highlight mouseover event handler
Diffstat (limited to 'lib/scripts/script.js')
-rw-r--r-- | lib/scripts/script.js | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/scripts/script.js b/lib/scripts/script.js index bf6f41ce5..27d088584 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -78,16 +78,15 @@ function getElementsByClass(searchClass,node,tag) { /** * Get the X offset of the top left corner of the given object * - * @link http://www.quirksmode.org/index.html?/js/findpos.html + * @link http://www.quirksmode.org/js/findpos.html */ function findPosX(object){ var curleft = 0; var obj = $(object); if (obj.offsetParent){ - while (obj.offsetParent){ + do { curleft += obj.offsetLeft; - obj = obj.offsetParent; - } + } while (obj = obj.offsetParent); } else if (obj.x){ curleft += obj.x; @@ -98,16 +97,15 @@ function findPosX(object){ /** * Get the Y offset of the top left corner of the given object * - * @link http://www.quirksmode.org/index.html?/js/findpos.html + * @link http://www.quirksmode.org/js/findpos.html */ function findPosY(object){ var curtop = 0; var obj = $(object); if (obj.offsetParent){ - while (obj.offsetParent){ + do { curtop += obj.offsetTop; - obj = obj.offsetParent; - } + } while (obj = obj.offsetParent); } else if (obj.y){ curtop += obj.y; @@ -535,7 +533,7 @@ addInitEvent(function(){ var btns = getElementsByClass('btn_secedit',document,'form'); for(var i=0; i<btns.length; i++){ addEvent(btns[i],'mouseover',function(e){ - var tgt = e.target.form.parentNode; + var tgt = this.parentNode; var nr = tgt.className.match(/(\s+|^)editbutton_(\d+)(\s+|$)/)[2]; do { tgt = tgt.previousSibling; |