[dokuwiki] Re: editsections plugin and latest dokuwiki version

  • From: maialen otaegi <siameiz@xxxxxxxxxxx>
  • To: dokuwiki freelists <dokuwiki@xxxxxxxxxxxxx>
  • Date: Mon, 29 Nov 2010 16:19:11 +0100

> Date: Sun, 28 Nov 2010 15:23:16 +0100
> Subject: [dokuwiki] editsections plugin and latest dokuwiki version
> From: dr4ke@xxxxxxxxx
> To: dokuwiki@xxxxxxxxxxxxx
> 
> Is there a way to implement this plugin without touching dokuwiki core ?
> 

Hello, I've implemented it using JavaScript, I remove the buttons and then put 
them before the headings. I didn't implement the nested choice, because I don't 
use it, but it can't be very difficult. I think it is a very simple solution, 
altought I don't know if it is the better one. 
 
this is the code:
 
addInitEvent(function(){

var content= getElementsByClass("content", document, 'div');
var buttons= getElementsByClass("editbutton_section", document, 'div');
/* Change buttons positions */
for (i in buttons){

buttons[i].className.match(/editbutton_(\d+)/); 
var heading = getElementsByClass("sectionedit"+RegExp.$1);
content[0].removeChild(buttons[i]); 
content[0].insertBefore(buttons[i], heading[0]); 
}

var btns = getElementsByClass('btn_secedit',document,'form');
for(var i=0; i<btns.length; i++){

// Remove existing mouseover events
var btnhdls = btns[i].events['mouseover'];
for(btnhdl in btnhdls){

removeEvent(btns[i],'mouseover',btnhdls[btnhdl]);
}



addEvent(btns[i],'mouseover',function(e){

var tgt = this.parentNode; 
var nr = tgt.className.match(/(\s+|^)editbutton_(\d+)(\s+|$)/)[2];
tgt= tgt.nextSibling; 

while (typeof tgt.className === 'undefined' || 
tgt.className.match(/editbutton_section/) === null){


if (typeof tgt.className !== 'undefined') {

tgt.className += ' section_highlight';
}
tgt = tgt.nextSibling; 



}
 

addEvent(btns[i],'mouseout',function(e){

var secs = getElementsByClass('section_highlight');
for(var j=0; j<secs.length; j++){

secs[j].className = secs[j].className.replace(/section_highlight/g,'');
}
});
}

});                                       

Other related posts: