summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Lang <lang@cosmocode.de>2010-03-15 16:57:38 +0100
committerAdrian Lang <lang@cosmocode.de>2010-03-15 17:00:50 +0100
commitfda42deb082e4bdb560818a9c23b96f9312176d5 (patch)
tree00320dee9b6beee838bcdcdc55cb6dea013c690c
parentc7cb395c4ee1339709918b7675e91d3d3b10050d (diff)
downloadrpg-fda42deb082e4bdb560818a9c23b96f9312176d5.tar.gz
rpg-fda42deb082e4bdb560818a9c23b96f9312176d5.tar.bz2
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
-rw-r--r--lib/scripts/drag.js3
-rw-r--r--lib/scripts/edit.js3
-rw-r--r--lib/scripts/script.js16
3 files changed, 9 insertions, 13 deletions
diff --git a/lib/scripts/drag.js b/lib/scripts/drag.js
index 254eab4a6..169be5219 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 58433f25c..b756e9488 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 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;