From c6bcae18f5590f7ad3d55d8bb23a874e8a50e165 Mon Sep 17 00:00:00 2001 From: Adrian Lang <lang@cosmocode.de> Date: Fri, 16 Oct 2009 11:09:46 +0200 Subject: [PATCH] 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 --- lib/scripts/script.js | 9 +++++++-- 1 file 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){ -- GitLab