From d74aace9ed8079a5a2430f3c0cc56ff39934279b Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 28 Jul 2005 02:55:22 +0200 Subject: footnote fix: almagamate identical footnotes, insitu footnote popups darcs-hash:20050728005522-50fdc-f359021d5bcf602c2c403d37852196d5eeb4d473.gz --- lib/scripts/script.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'lib/scripts/script.js') diff --git a/lib/scripts/script.js b/lib/scripts/script.js index 9d667c7af..58785dbde 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -457,3 +457,47 @@ function checkAclLevel(){ } } } + +/* insitu footnote addition + * 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 + */ +var currentFootnote = 0; +function fnt(id, e, evt) { + + if (currentFootnote && id != currentFootnote) { + domTT_close(document.getElementById('insitu-fn'+currentFootnote)); + } + + // does the footnote tooltip already exist? + var fnt = document.getElementById('insitu-fn'+id); + if (!fnt) { + // if not create it... + + // locate the footnote anchor element + var a = document.getElementById( "fn"+id ); + if (!a) return; + + // anchor parent is the footnote container, get its innerHTML + var footnote = new String (a.parentNode.innerHTML); + + // strip the leading footnote anchors and their comma separators + footnote = footnote.replace(//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'); + + // create the DOM node, assign an id, a class and the footnote content + fnt = document.createElement("div"); + fnt.id = "insitu-fn"+id; + fnt.className = "insitu-footnote"; + fnt.innerHTML = footnote; + } + + // activate the tooltip + domTT_activate(e, evt, 'content', fnt, 'type', 'velcro'); + currentFootnote = id; +} -- cgit v1.2.3