summaryrefslogtreecommitdiff
path: root/lib/scripts/script.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/scripts/script.js')
-rw-r--r--lib/scripts/script.js44
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;
+}