Skip to content

Commit

Permalink
Various JavaScript fixes
Browse files Browse the repository at this point in the history
  * 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
  • Loading branch information
adrianheine committed Mar 15, 2010
1 parent c7cb395 commit fda42de
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
3 changes: 1 addition & 2 deletions lib/scripts/drag.js
Expand Up @@ -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');
}
},

}
};
3 changes: 1 addition & 2 deletions lib/scripts/edit.js
Expand Up @@ -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();
};
Expand Down
16 changes: 7 additions & 9 deletions lib/scripts/script.js
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit fda42de

Please sign in to comment.