diff --git a/lib/scripts/script.js b/lib/scripts/script.js index d2fbc35bfe4e724c0567559e3c1b946243ae1491..d621232cea5b17f9493479b07388baae040ddc81 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -117,11 +117,11 @@ function escapeQuotes(text) { * @see appendChild() */ function prependChild(parent,element) { - if(!parent.firstChild){ - parent.appendChild(element); - }else{ - parent.insertBefore(element,parent.firstChild); - } + if(!parent.firstChild){ + parent.appendChild(element); + }else{ + parent.insertBefore(element,parent.firstChild); + } } /** @@ -153,8 +153,8 @@ function hideLoadBar(){ * @see http://www.alexking.org/index.php?content=software/javascript/content.php */ function mediaSelect(file){ - opener.insertAtCarret('wikitext','{{'+file+'}}'); - window.close(); + opener.insertTags('wikitext','{{'+file+'|','}}',file); + window.close(); } /** @@ -173,23 +173,23 @@ function suggestWikiname(){ * Adds the toggle switch to the TOC */ function addTocToggle() { - if(!document.getElementById) return; - var header = $('toc__header'); + if(!document.getElementById) return; + var header = $('toc__header'); if(!header) return; var showimg = document.createElement('img'); - showimg.id = 'toc__show'; + showimg.id = 'toc__show'; showimg.src = DOKU_BASE+'lib/images/arrow_down.gif'; showimg.alt = '+'; - showimg.onclick = toggleToc; + showimg.onclick = toggleToc; showimg.style.display = 'none'; - var hideimg = document.createElement('img'); - hideimg.id = 'toc__hide'; + var hideimg = document.createElement('img'); + hideimg.id = 'toc__hide'; hideimg.src = DOKU_BASE+'lib/images/arrow_up.gif'; hideimg.alt = '-'; - hideimg.onclick = toggleToc; - + hideimg.onclick = toggleToc; + prependChild(header,showimg); prependChild(header,hideimg); } @@ -289,7 +289,7 @@ function checkAclLevel(){ * * provide a wrapper for domTT javascript library * this function is placed in the onmouseover event of footnote references in the main page - * + * * @author Chris Smith <chris [at] jalakai [dot] co [dot] uk> */ var currentFootnote = 0; @@ -298,33 +298,33 @@ function fnt(id, e, evt) { if (currentFootnote && id != currentFootnote) { domTT_close($('insitu-fn'+currentFootnote)); } - + // does the footnote tooltip already exist? var fnote = $('insitu-fn'+id); var footnote; if (!fnote) { // if not create it... - + // locate the footnote anchor element - var a = $( "fn"+id ); + var a = $( "fn"+id ); if (!a){ return; } - + // anchor parent is the footnote container, get its innerHTML footnote = new String (a.parentNode.innerHTML); - + // strip the leading footnote anchors and their comma separators footnote = footnote.replace(/<a\s.*?href=\".*\#fnt\d+\".*?<\/a>/gi, ''); footnote = footnote.replace(/^\s+(,\s+)+/,''); - + // prefix ids on any elements with "insitu-" to ensure they remain unique footnote = footnote.replace(/\bid=\"(.*?)\"/gi,'id="insitu-$1'); - } else { + } else { footnote = new String(fnt.innerHTML); } - + // activate the tooltip domTT_activate(e, evt, 'content', footnote, 'type', 'velcro', 'id', 'insitu-fn'+id, 'styleClass', 'insitu-footnote JSpopup', 'maxWidth', document.body.offsetWidth*0.4); - currentFootnote = id; + currentFootnote = id; } @@ -332,7 +332,7 @@ function fnt(id, e, evt) { * Add the edit window size controls */ function initSizeCtl(ctlid,edid){ - if(!document.getElementById){ return; } + if(!document.getElementById){ return; } var ctl = $(ctlid); var textarea = $(edid); @@ -348,8 +348,8 @@ function initSizeCtl(ctlid,edid){ var s = document.createElement('img'); l.src = DOKU_BASE+'lib/images/larger.gif'; s.src = DOKU_BASE+'lib/images/smaller.gif'; - addEvent(l,'click',function(){sizeCtl(edid,100);}); - addEvent(s,'click',function(){sizeCtl(edid,-100);}); + addEvent(l,'click',function(){sizeCtl(edid,100);}); + addEvent(s,'click',function(){sizeCtl(edid,-100);}); ctl.appendChild(l); ctl.appendChild(s); } @@ -378,7 +378,7 @@ function closePopups(){ var divs = document.getElementsByTagName('div'); for(var i=0; i < divs.length; i++){ if(divs[i].className.indexOf('JSpopup') != -1){ - divs[i].style.display = 'none'; + divs[i].style.display = 'none'; } } } @@ -387,6 +387,6 @@ function closePopups(){ * Looks for an element with the ID scroll__here at scrolls to it */ function scrollToMarker(){ - var obj = $('scroll__here'); - if(obj) obj.scrollIntoView(); + var obj = $('scroll__here'); + if(obj) obj.scrollIntoView(); }