diff options
author | chris <chris@teacherscpd.co.uk> | 2005-07-28 02:55:22 +0200 |
---|---|---|
committer | chris <chris@teacherscpd.co.uk> | 2005-07-28 02:55:22 +0200 |
commit | d74aace9ed8079a5a2430f3c0cc56ff39934279b (patch) | |
tree | 387fd4b0cedbac9eb3cebeeea6386e0bd4c8db7a /lib/scripts/script.js | |
parent | 4468cb4c2906e2ae8887839b5e683cfc01c7b12c (diff) | |
download | dokuwiki-d74aace9ed8079a5a2430f3c0cc56ff39934279b.tar.gz dokuwiki-d74aace9ed8079a5a2430f3c0cc56ff39934279b.zip |
footnote fix: almagamate identical footnotes, insitu footnote popups
darcs-hash:20050728005522-50fdc-f359021d5bcf602c2c403d37852196d5eeb4d473.gz
Diffstat (limited to 'lib/scripts/script.js')
-rw-r--r-- | lib/scripts/script.js | 44 |
1 files changed, 44 insertions, 0 deletions
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 <chris [at] jalakai [dot] co [dot] uk> + */ +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(/<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'); + + // 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; +} |