Need help customizing YUI tool

I really like the tool found here:
but there are a couple of changes I'd like to make, although, I can't figure out how to add it in there, and there doesn't seem to be any information in the forums.  

I want the window to popup *beside* the link, instead of over it, and I want the link to be aligned to the vertical middle of the tooltip.  Does anyone know (or are even familiar enough with YUI) to explain how to do this, or even if it's possible?  Thanks!
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Eddie ShipmanConnect With a Mentor All-around developerCommented:
Make the following change, to the example. It will align to the bottom right of the button. The only
options you have are TOP_LEFT (tl), TOP_RIGHT (tr), BOTTOM_LEFT (bl), and BOTTOM_RIGHT (br).
The context:["button1", "tl", "br"] aligns the top left (tl) of the panel to the bottom right (br) of
the button1 element.

I don't see a way to get the position of an anchor (link) to be able to set the XY coords.

Make sure you give your buttons an id like in the HTML below.

YAHOO.example.container.myPanel = new YAHOO.widget.Panel("myPanel", 
                                  { context:["button1","tl","br"], 
                                    draggable:true } );
<button id="button1" onclick="">Show panel</button>
<button id="button2" onclick="YAHOO.example.container.myPanel.hide()">Hide panel</button>

Open in new window


I'm trying to do a similar job in YUI but with Tooltips. Below is a snippet of my code. Any element with hoversymbol class displays a tooltip. I have failed to place the tooltip("tl","tr") by using the positioning configurationas you can see in my code.

// Symbol cells should have the class "hoversymbol".
// Needs the following libraries
//      css/container.css
//      js/yui/yahoo-dom-event.js
//      js/yui/container.js
//      js/yui/element-beta.js
var overlay;
var storedSymbolInfo = {
  ADP : {name: 'AUTOMATIC DATA PROC', price: 45.17, change: 0.86, percent: 1.87 },
  BR : {name: 'BROADRIDGE FINANCIAL', price: 22.35, change: 0.19, percent: 8.51 },
  MSFT : {name: 'MICROSOFT', price: 34.76, change: 0.04, percent: 0.12 }
var toolTip;
function init() {
      var symbolCells = YAHOO.util.Dom.getElementsByClassName('hoversymbol', 'TD');
      overlay = new YAHOO.widget.Overlay("myOverlay",{visible:false,width:"175px" } );
      toolTip = new YAHOO.widget.Tooltip("myToolTip", {context:[symbolCells,"tl","tr"],
            function(type, args){
                  var context = args[0];
                  var cellElement = new YAHOO.util.Element(context);
                  if (displayedInfo && displayedInfo.symbolCell != cellElement) {
                  displayedInfo.symbolCell = cellElement;
                  console.log("tool tip mouseover event");
            function(type, args){
                  console.log("tooltip mouseout event");      
      YAHOO.util.Event.addListener(toolTip, "mouseover", extendTooltipLife);
      YAHOO.util.Event.addListener(toolTip, "mouseout", hideTooltip);
      console.log("init completed");

function hideTooltip(e){
      console.log("mouseout tooltip");

function extendTooltipLife(e){
      console.log("mouseover tooltip");

function displaySymbolInfo(theCell){

      var cellElement = new YAHOO.util.Element(theCell);
      if(displayedInfo && displayedInfo.symbolCell != cellElement){
      var symbol = cellElement.getElementsByTagName('A')[0].innerHTML;
      var companyName;
      var headerString
      var symbolInfo = storedSymbolInfo[symbol];
      if (storedSymbolInfo[symbol]) {
            headerString = '<table border="0" width="100%"><tr><td align="center">';
            headerString += symbolInfo.price + '</td><td align="center" class="positive">+';
            headerString += symbolInfo.change + '</td><td align="center" class="positive">';
            headerString += symbolInfo.percent + '%</td></tr></table>';
            companyName = "&nbsp;<b>" + + "</b><br>";
      var chartNav = '<div class="chartbar"><div class="chartoption selected">1d</div><div class="chartoption">5d</div>';
      chartNav += '<div class="chartoption">3m</div><div class="chartoption">6m</div><div class="chartoption">1y</div>';
      chartNav += '<div class="chartoption">2y</div><div class="chartoption">5y</div><br clear="all"/></div>';
      text = headerString+companyName + "<img src='"+symbol+"&chmrg=3&chscale=3m&chwid=130&chhig=130&chsym=""' border='0' hspace='5'><br>" + chartNav+
                      '<span class="chartlinks">&nbsp;News | Profile | Stats | Chart<br>&nbsp;Quote | Option Chain | Trade</span>';
      toolTip.symbolCell = cellElement;
      displayedInfo = toolTip;
      toolTip.cfg.setProperty("text", text);
      //YAHOO.util.Event.addListener(overlay.element, "mouseover", showSymbolInfo, overlay);
      //YAHOO.util.Event.addListener(overlay.element, "mouseout", timeoutSymbolInfo, overlay);
function showSymbolInfo(e, theOverlay) {
      if (displayedInfo && displayedInfo != theOverlay) {
      displayedInfo = theOverlay;

function timeoutSymbolInfo(e, theOverlay) {
      if (displayedInfo && displayedInfo != theOverlay) {
            displayedInfo.pause = setTimeout(hideDetails,300);

function hideDetails() {
var displayedInfo;

YAHOO.util.Event.addListener(window, "load", init);

HTML code:

<div class="pagecontainer yui-skin-sam">
      <div class="pagecontents">
            <form name="AccountActivityForm" method="link" action="accountactivity.htm">
            <table border="0" cellpadding="1" cellspacing="0">
                  <tr class="columnheadings">
                        <th align="left" id="column-symbol">
                              <span class="labeldark"><a href="" onclick="return false;">Symbol</a></span>
                  <tr class="rowshade_odd">
                        <td align="left" class="hoversymbol column-symbol Stock_US" nowrap>
                              <a href="#" class="Stock_US">ADP</a>
                  <tr class="rowshade_even">
                                          <td align="left" class="hoversymbol column-symbol Stock_US" nowrap>
                                                <a href="#" class="Stock_US">BR</a>
                  <tr class="rowshade_odd">
                                          <td align="left" class="hoversymbol column-symbol Stock_US" nowrap>
                                                <a href="#" class="Stock_US">MSFT</a>
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.