Skip to content

Commit

Permalink
Fixed child toolbar positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
james119 committed Dec 7, 2008
1 parent 6bc640c commit ae13a51
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 9 deletions.
20 changes: 11 additions & 9 deletions jtoolbar.js
Expand Up @@ -616,11 +616,8 @@ var JTB = function() {
else {
// link is actually a nested toolbar
var tbName = this.link.getToolbarName();
//return '<div onmouseover=\"document.write(\'Come on\');\")>' + this.name + '</div>';

return '<div onmouseover=\"JTB.showChildToolbar(\'' + tbName + '\', 100, 100)\">' + this.name + '</div>';

//return '<div onmouseover=\"JTB.showChildToolbar(' + tbName + ', JTB.findXOffset(' + tbName + ', event)' + ', JTB.findYOffset(' + tbName + ', event))" style="display: ' + displayStyle + '">' + this.name + '</div>';
//return '<div onmouseover=\"JTB.showChildToolbar(\'' + tbName + '\', 100, 100)\">' + this.name + '</div>';
return '<div onmouseover=\"JTB.showChildToolbar(\'' + tbName + '\', JTB.findXOffset(\'' + tbName + '\', event)' + ', JTB.findYOffset(\'' + tbName + '\', event))\" style=\"display: ' + displayStyle + '">' + this.name + '</div>';
}
};

Expand Down Expand Up @@ -1890,10 +1887,13 @@ var JTB = function() {
var linkDiv = event.target;
var parentToolbar = childToolbar.getParentToolbar();
var orient = parentToolbar.getOrientation();
// Remove the units from the width string
var w = parentToolbar.e_tb.style.width;
w = w.substr(0,w.length-2);
if (orient == JTB.ORIENT_LEFT) {
return (linkDiv.offsetLeft + parentToolbar.e_tb.width);
return linkDiv.offsetLeft + (+w);
} else if (orient == JTB.ORIENT_RIGHT) {
return (linkDiv.offsetLeft - childToolbar.e_tb.width);
return linkDiv.offsetLeft - (+w);
} else {
return linkDiv.offsetLeft;
}
Expand All @@ -1905,10 +1905,12 @@ var JTB = function() {
var linkDiv = event.target;
var parentToolbar = childToolbar.getParentToolbar();
var orient = parentToolbar.getOrientation();
var h = parentToolbar.e_tb.style.height;
h = h.substr(0,h.length-2);
if (orient == JTB.ORIENT_TOP) {
return (linkDiv.offsetTop + parentToolbar.e_tb.height);
return linkDiv.offsetTop + (+h);
} else if (orient == JTB.ORIENT_BOTTOM) {
return (linkDiv.offsetTop - childToolbar.e_tb.height);
return linkDiv.offsetTop - (+h);
} else {
return linkDiv.offsetTop;
}
Expand Down
54 changes: 54 additions & 0 deletions test/nested_test.html
@@ -0,0 +1,54 @@
<html>
<body>
<div id="tempest" style="border: 1px solid #000; background-color: #AAAAAA;
padding: 0 10px 0 10px; width: 800px; height: 350px;">
<p style="text-align:center"><b><u>The Tempest</u></b></p>

<p>
Now would I give a thousand furlongs of sea for an
acre of barren ground, long heath, brown furze, any
thing. The wills above be done! but I would fain
die a dry death.
</p>

<p>
I prithee, let me bring thee where crabs grow;
And I with my long nails will dig thee pignuts;
Show thee a jay's nest and instruct thee how
To snare the nimble marmoset; I'll bring thee
To clustering filberts and sometimes I'll get thee
Young scamels from the rock. Wilt thou go with me?
</p>

<p>
How many goodly creatures are there here!
How beauteous mankind is! O brave new world,
That has such people in't!
</p>
</div>

<div id="custom_toolbar" style="width:100px; background-color:#FAA;">
<p align="center"><b>LINKS</b></p>
</div>

<div id="debug" style="position:absolute; top:500px; background-color:#777777" onmouseover="document.getElementById('debug').innerHTML = 'hello world!'"> hello </div>

<script src="../jtoolbar.js"></script>
<script>
var parentName = "tempest";
var toolbarName = "custom_toolbar";
var nt = new JTB.Toolbar(null, "nested_tb1", "Stanford", "http://www.stanford.edu", "Berkeley", "http://www.berkeley.edu");
nt.setImagePath('../images/');
var nt2 = new JTB.Toolbar(null, "nested_tb2", "Google", "http://www.google.com", "Yahoo", "http://www.yahoo.com");
nt2.setImagePath('../images/');
var t = new JTB.Toolbar(parentName, toolbarName, "dound", "http://www.dound.com", "Schools", nt, "Search", nt2);
t.setImagePath('../images/');
//t.setDebugMode(true);
//t.setFloatPos(50,50).setDocked(false);
//setTimeout('t.setOrientation(JTB.ORIENT_TOP);', 1000);
//setTimeout('t.setOrientation(JTB.ORIENT_BOTTOM);', 2000);
//setTimeout('t.setOrientation(JTB.ORIENT_RIGHT);', 3000);
//setTimeout('t.setOrientation(JTB.ORIENT_LEFT);', 4000);
</script>
</body>
</html>

0 comments on commit ae13a51

Please sign in to comment.