Bug 6252, making tinderbox popups work for Mozilla. The code comes from

dbaron@fas.harvard.edu, and I modified the browser version detection
code slightly.
This commit is contained in:
dveditz%netscape.com 2000-04-20 00:50:15 +00:00
Родитель e4da0f4eff
Коммит ce6fc83d6c
1 изменённых файлов: 129 добавлений и 41 удалений

Просмотреть файл

@ -526,16 +526,65 @@ sub tree_open {
sub print_javascript { sub print_javascript {
my $script; my $script;
($script = <<"__ENDJS") =~ s/^ //gm; ($script = <<"__ENDJS") =~ s/^ //gm;
<style type="text/css">
#popup {
position: absolute;
height: 10em;
margin: -5em 0 0 -5em;
}
.who#popup{
width: 20em;
}
.note#popup {
width: 25em;
height: 20em;
}
.log#popup {
width: 15em;
}
.note#popup, .log#popup {
border: 2px solid black;
background: white;
color: black;
padding: 0.5em;
}
</style>
<script> <script>
var noDHTML = false;
if (parseInt(navigator.appVersion) < 4) { if (parseInt(navigator.appVersion) < 4) {
window.event = 0; window.event = 0;
noDHTML = true;
} else if (navigator.userAgent.indexOf("MSIE") > 0 ) {
noDHTML = true;
}
if (document.body && document.body.addEventListener) {
document.body.addEventListener("click",maybeclosepopup,false);
}
function nodewrite(n,t) {
var r = document.createRange();
r.setStart(n,0);
n.appendChild(r.createContextualFragment(t));
}
function closepopup() {
var p = document.getElementById("popup");
if (p && p.parentNode) {
p.parentNode.removeChild(p);
}
}
function maybeclosepopup(e) {
var n = e.target;
var close = true;
while(close && n && (n != document)) {
close = (n.id != "popup") && !(n.tagName && (n.tagName.toLowerCase() == "a"));
n = n.parentNode;
}
if (close) closepopup();
} }
function who(d) { function who(d) {
var version = parseInt(navigator.appVersion); if (noDHTML) {
if (version < 4 || version >= 5) {
return true; return true;
} }
if (document.layers) {
var l = document.layers['popup']; var l = document.layers['popup'];
l.src = d.target.href; l.src = d.target.href;
l.top = d.target.y - 6; l.top = d.target.y - 6;
@ -544,22 +593,33 @@ sub print_javascript {
l.left = window.width - l.clipWidth; l.left = window.width - l.clipWidth;
} }
l.visibility="show"; l.visibility="show";
} else {
var t = d.target;
while (t.nodeType != 1) {
t = t.parentNode;
}
closepopup()
var l = document.createElement("iframe");
l.setAttribute("src", t.href);
l.setAttribute("id", "popup");
l.className = "who";
t.appendChild(l);
}
return false; return false;
} }
function log_url(logfile) { function log_url(logfile) {
return "${rel_path}showlog.cgi?log=" + buildtree + "/" + logfile; return "${rel_path}showlog.cgi?log=" + buildtree + "/" + logfile;
} }
function note(d,noteid,logfile) { function note(d,noteid,logfile) {
var version = parseInt(navigator.appVersion); if (noDHTML) {
if (version < 4 || version >= 5) {
document.location = log_url(logfile); document.location = log_url(logfile);
return false; return false;
} }
if (document.layers) {
var l = document.layers['popup']; var l = document.layers['popup'];
l.document.write("<table border=1 cellspacing=1><tr><td>" l.document.write("<table border=1 cellspacing=1><tr><td>"
+ notes[noteid] + "</tr></table>"); + notes[noteid] + "</tr></table>");
l.document.close(); l.document.close();
l.top = d.y-10; l.top = d.y-10;
var zz = d.x; var zz = d.x;
if (zz + l.clip.right > window.innerWidth) { if (zz + l.clip.right > window.innerWidth) {
@ -568,18 +628,31 @@ sub print_javascript {
} }
l.left = zz; l.left = zz;
l.visibility="show"; l.visibility="show";
} else {
var t = d.target;
while (t.nodeType != 1) {
t = t.parentNode;
}
closepopup()
var l = document.createElement("div");
nodewrite(l,notes[noteid]);
l.setAttribute("id", "popup");
l.style.position = "absolute";
l.className = "note";
t.parentNode.parentNode.appendChild(l);
}
return false; return false;
} }
function log(e,buildindex,logfile) function log(e,buildindex,logfile)
{ {
var logurl = log_url(logfile); var logurl = log_url(logfile);
var commenturl = "${rel_path}addnote.cgi?log=" + buildtree + "/" + logfile; var commenturl = "${rel_path}addnote.cgi?log=" + buildtree + "/" + logfile;
var version = parseInt(navigator.appVersion);
if (version < 4 || version >= 5) { if (noDHTML) {
document.location = logurl; document.location = logurl;
return false; return false;
} }
if (document.layers) {
var q = document.layers["logpopup"]; var q = document.layers["logpopup"];
q.top = e.target.y - 6; q.top = e.target.y - 6;
@ -597,6 +670,21 @@ sub print_javascript {
+ "<A HREF=" + commenturl + ">Add a Comment</A>" + "<A HREF=" + commenturl + ">Add a Comment</A>"
+ "</TD></TR></TABLE>"); + "</TD></TR></TABLE>");
q.document.close(); q.document.close();
} else {
var t = e.target;
while (t.nodeType != 1) {
t = t.parentNode;
}
closepopup();
var l = document.createElement("div");
nodewrite(l,"<B>" + builds[buildindex] + "</B><BR>"
+ "<A HREF=" + logurl + ">View Brief Log</A><BR>"
+ "<A HREF=" + logurl + "&fulltext=1"+">View Full Log</A><BR>"
+ "<A HREF=" + commenturl + ">Add a Comment</A><BR>");
l.setAttribute("id", "popup");
l.className = "log";
t.parentNode.appendChild(l);
}
return false; return false;
} }