/*
* Rich HTML Balloon Tooltip to display references
* adapted from http://www.dynamicdrive.com/dynamicindex5/balloontooltip.htm
*/
var disappeardelay = 500; // tooltip disappear delay (in miliseconds)
var current_tooltip; // global to store the citekey of most recently retrieved refdb record
function tooltipForRecordId(obj, e, record_id){
return displayballoontip(obj, e, 'refdb', record_id);
}
function tooltipForCitekey(obj, e, pubNo, citekey){
return displayballoontip(obj, e, 'refdb', pubNo+'-'+citekey);
}
function tooltipForPubNo(obj, e, pubNo){
return displayballoontip(obj, e, 'register', pubNo);
}
function displayballoontip(obj, e, type, record){ //main ballooon tooltip function
var tooltip_id = type+record;
if (window.event) {event.cancelBubble=true;}
else if (e.stopPropagation) {e.stopPropagation();}
if (typeof dropmenuobj!="undefined"){ //hide previous tooltip?
dropmenuobj.style.visibility="hidden";
}
clearhidemenu();
dropmenuobj = document.getElementById('tooltip_display');
if (e.type=="mouseover"){dropmenuobj.style.visibility="visible";}
if (tooltip_id != current_tooltip) {
// we got to make a new ajax call
unapiRequest2(type, record, 'html-fragment', 'tooltip_display');
current_tooltip = tooltip_id;
}
// now compute the mouse position:
var posx = 0;
var posy = 0;
if (!e) var e = window.event;
if (e.pageX || e.pageY) {
posx = e.pageX;
posy = e.pageY;
}
else if (e.clientX || e.clientY) {
posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}
// it turns out that the most usable way of displaying the tooltips is to center
// them horizontally.
//dropmenuobj.style.left = posx+"px";
dropmenuobj.style.left = '30%';
posy = posy + 13;
dropmenuobj.style.top = posy+"px";
}
function unapiRequest2(type, id, format, display) {
ajaxRequest('/'+type+'/unapi?format='+format+'&id='+id, unapiResponse2, display);
}
function unapiResponse2(text, display) {
try {
document.getElementById(display).innerHTML = text;
} catch(e) {}
}
function delayhidemenu(){
delayhide = setTimeout("dropmenuobj.style.visibility='hidden'; dropmenuobj.style.left=0;", disappeardelay);
return false;
}
function clearhidemenu(){if (typeof delayhide!="undefined"){clearTimeout(delayhide);}}
function initalizetooltip(pubNo){
var display = document.createElement("div");
display.setAttribute("id", "tooltip_display");
display.className = "balloonstyle";
document.body.appendChild(display);
var head = document.getElementsByTagName('head')[0];
var script = document.createElement("script");
script.setAttribute("src", "/js/ajax.js");
head.appendChild(script);
var css = ".balloonstyle{text-align:left;position:absolute;top: 0;left: 0;padding: 5px;visibility: hidden;border:1px solid black;font:normal 12px Verdana;line-height: 18px;z-index: 100;background-color: white;width: 35em;-moz-border-radius: 5px;-webkit-border-radius: 5px;-webkit-box-shadow: 0 5px 10px rgba(0,0,0,.5);-moz-box-shadow: 0 5px 10px rgba(0,0,0,.5);box-shadow: 0 5px 10px rgba(0,0,0,.5);/*Remove below line to remove shadow. Below line should always appear last within this CSS*/filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135,Strength=5);}";
var style = document.createElement("style");
style.setAttribute("type","text/css");
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
var all_links = document.getElementsByTagName("a");
for (var i=0; i 0){
all_links[i].removeAttribute('title');
all_links[i].onmouseover = function(e){
var evtobj = window.event? window.event : e;
// we parse the citekey from the links href attribute, which is expected to
// look like javascript:parent.bibpopup('refs.html#ref-Brown1971')
var citekey = this.href.split('#')[1]
// the citekey may be prefixed with 'ref-', e.g. for lrsp articles
if (citekey.indexOf('ref-') == 0){citekey = citekey.substring(4)}
if (citekey.indexOf("')") != -1){citekey = citekey.split("')")[0];}
tooltipForCitekey(this, evtobj, pubNo, citekey);
return false;
}
all_links[i].onmouseout = delayhidemenu;
} else if (/\/refdb\/record\/\d+$/.test(all_links[i].href)){
all_links[i].removeAttribute('title');
all_links[i].onmouseover = function(e){
var evtobj = window.event? window.event : e;
// we parse the record id from the links href attribute, which is expected to
// look like http:///refdb/record/
var record_id = this.href.split('/refdb/record/')[1]
tooltipForRecordId(this, evtobj, record_id);
return false;
}
all_links[i].onmouseout = delayhidemenu;
} else if (/\/Articles\//.test(all_links[i].href) && all_links[i].href.indexOf('refs.html#') > 0){
all_links[i].removeAttribute('title');
all_links[i].onmouseover = function(e){
var evtobj = window.event? window.event : e;
// we parse the pubNo from the links href attribute, which is expected to
// look like http:///Articles//refs.html#ref-Brown1971
var pub_no = this.href.split('/Articles/')[1]
pub_no = pub_no.split('/')[0]
tooltipForPubNo(this, evtobj, pub_no);
return false;
}
all_links[i].onmouseout = delayhidemenu;
} else if (all_links[i].attributes['class'] && all_links[i].attributes['class'].nodeValue == 'search-result' && /[a-z]{3,4}\-[0-9]{4}\-[0-9]+/.test(all_links[i].href)){
all_links[i].removeAttribute('title');
all_links[i].onmouseover = function(e){
var evtobj = window.event? window.event : e;
var pub_no = /[a-z]{3,4}\-[0-9]{4}\-[0-9]+/.exec(this.href)[0]
tooltipForPubNo(this, evtobj, pub_no);
return false;
}
}
}
}
.