summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Lang <lang@cosmocode.de>2009-10-16 11:09:46 +0200
committerAdrian Lang <lang@cosmocode.de>2009-10-16 11:09:46 +0200
commitc6bcae18f5590f7ad3d55d8bb23a874e8a50e165 (patch)
tree51ba811db08508649f9894c98e40c3bb1ac2a864
parentd85fc3586a46a48ee5896c125d867fb1aaa33b25 (diff)
downloadrpg-c6bcae18f5590f7ad3d55d8bb23a874e8a50e165.tar.gz
rpg-c6bcae18f5590f7ad3d55d8bb23a874e8a50e165.tar.bz2
Fix paragraph highlighting for mouseover on edit buttons
Dokuwiki does not generate section edit buttons for h4 sections. Therefor, the edit button next to a h4 section belongs to a previous higher-level section. The AJAX-y paragraph highlighting onmouseover the edit button does not highlight all sections up to to higher-level section which owns the edit button, but only the last, i. e. h4 section. This patch highlights all sections up to the heading the edit button refers to. darcs-hash:20091016090946-e4919-fa9ed1f627a6cab9654eb66c5fb4760f3d4d9fcf.gz
-rw-r--r--lib/scripts/script.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/scripts/script.js b/lib/scripts/script.js
index 032741397..418d2f069 100644
--- a/lib/scripts/script.js
+++ b/lib/scripts/script.js
@@ -557,6 +557,7 @@ addInitEvent(function(){
* @author Andreas Gohr <andi@splitbrain.org>
*/
addInitEvent(function(){
+ var highlightorfinish = new RegExp('DIV|H[123]');
var btns = getElementsByClass('btn_secedit',document,'form');
for(var i=0; i<btns.length; i++){
addEvent(btns[i],'mouseover',function(e){
@@ -564,8 +565,12 @@ addInitEvent(function(){
if(tgt.form) tgt = tgt.form;
tgt = tgt.parentNode.previousSibling;
if(tgt.nodeName != "DIV") tgt = tgt.previousSibling;
- if(tgt.nodeName != "DIV") return;
- tgt.className += ' section_highlight';
+ while(tgt.nodeName == 'DIV') {
+ tgt.className += ' section_highlight';
+ do {
+ tgt = (tgt.previousSibling != null) ? tgt.previousSibling : tgt.parentNode;
+ } while (!highlightorfinish.test(tgt.nodeName));
+ }
});
addEvent(btns[i],'mouseout',function(e){