From fda42deb082e4bdb560818a9c23b96f9312176d5 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 15 Mar 2010 16:57:38 +0100 Subject: [PATCH] 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 --- lib/scripts/drag.js | 3 +-- lib/scripts/edit.js | 3 +-- lib/scripts/script.js | 16 +++++++--------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/scripts/drag.js b/lib/scripts/drag.js index 254eab4a69..169be5219f 100644 --- a/lib/scripts/drag.js +++ b/lib/scripts/drag.js @@ -83,6 +83,5 @@ var drag = { this.obj.style.top = (e.pageY+this.oY-this.eY+'px'); this.obj.style.left = (e.pageX+this.oX-this.eX+'px'); } - }, - + } }; diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index 58433f25c1..b756e94884 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -386,8 +386,7 @@ var locktimer = new locktimer_class(); locktimer.sack.onCompletion = locktimer.refreshed; // register refresh event - addEvent($('dw__editform').elements.wikitext,'keypress',function(){locktimer.refresh();}); - + addEvent($('dw__editform'),'keypress',function(){locktimer.refresh();}); // start timer locktimer.reset(); }; diff --git a/lib/scripts/script.js b/lib/scripts/script.js index bf6f41ce5d..27d0885845 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