Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Tooltip in grid/columns layout, doesn't show over all images
Old 07-13-2010, 10:09 AM Tooltip in grid/columns layout, doesn't show over all images
Junior Talker

Posts: 2
Name: Leonardo Duarte
Trades: 0
Hi,

I am using osCommerce, (I already posted in their forums but until now no one seems to know an answer).
I am trying intensively for about 3 days, and without much sleep to resolve this problem.

I am using IMAGE WITH DESCRIPTION TOOLTIP (http://addons.oscommerce.com/info/4594) in my OSC product_listing.php file, but it won't work because my file is not the standard one that has one single vertical row, I am using product listing in a grid or columns layout, so the correct tip image doesn't show over all products, instead it repeats the same image across the columns.

I will appreciate very much if someone can pointing me out what should I modify in product_listing.php javascrip code in order to work properly.

I post here the product_listing.php code entirely.

product_listing.php code:
------------------------------------------------------------------------------
PHP Code:
 
<?php
/*
$Id: product_listing.php 1739 2007-12-20 00:52:16Z hpdl $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/
 
define('PRODUCT_LIST_COLUMNS'3);
 
$listing_split = new splitPageResults($listing_sqlMAX_DISPLAY_SEARCH_RESULTS'p.products_id');
 
if ( (
$listing_split->number_of_rows 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
<td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE ' ' $listing_split->display_links(MAX_DISPLAY_PAGE_LINKStep_get_all_get_params(array('page''info''x''y'))); ?></td>
</tr>
</table>
<?php
}
 
if (
tep_not_null($_GET['manufacturers_id'])) {
$manufacturer_query tep_db_query(
"select manufacturers_name
from " 
TABLE_MANUFACTURERS "
where manufacturers_id = '" 
tep_db_input($_GET['manufacturers_id']) . "';"
);
$manufacturer tep_db_fetch_array($manufacturer_query);
$info_box_header $manufacturer['manufacturers_name'];
if (
tep_not_null($_GET['filter_id'])) {
$category_query tep_db_query(
"select cd.categories_name
from
TABLE_CATEGORIES " c,
TABLE_CATEGORIES_DESCRIPTION " cd
where c.categories_id = '" 
tep_db_input($_GET['filter_id']) . "'
and cd.categories_id = '" 
tep_db_input($_GET['filter_id']) . "'
and cd.language_id = '" 
. (int)$languages_id "'"
);
$category tep_db_fetch_array($category_query);
$info_box_header .= ' &gt; '$category['categories_name'];
}
}
 
if (
tep_not_null($current_category_id)) {
$category_query tep_db_query(
"select cd.categories_name
from
TABLE_CATEGORIES " c,
TABLE_CATEGORIES_DESCRIPTION " cd
where c.categories_id = '" 
. (int)$current_category_id "'
and cd.categories_id = '" 
. (int)$current_category_id "'
and cd.language_id = '" 
. (int)$languages_id "'"
);
$category tep_db_fetch_array($category_query);
$info_box_header $category['categories_name'];
}
 
$info_box_contents = array();
// $info_box_contents[] = array('text' => $info_box_header);
// new contentBoxHeading($info_box_contents);
$row 0;
$col 0;
$list_box_contents = array();
if (
$listing_split->number_of_rows 0) {
$listing_query tep_db_query($listing_split->sql_query);
$cnt 0;
?>
<script language="javascript" type="text/javascript">
<!--
 
/*
Image w/ description tooltip- By Dynamic Web Coding (www.dyn-web.com)
Copyright 2002 by Sharon Paine
Visit http://www.dynamicdrive.com for this script
*/
 
/* IMPORTANT: Put script after tooltip div or
put tooltip div just before </BODY>. */
 
var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;
 
// resize fix for ns4
var origWidth, origHeight;
if (ns4) {
origWidth = window.innerWidth; origHeight = window.innerHeight;
window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}
 
// avoid error of passing event object in older browsers
if (nodyn) { event = "nope" }
 
/////////////////////// CUSTOMIZE HERE ////////////////////
// settings for tooltip
// Do you want tip to move when mouse moves over link?
var tipFollowMouse= true;
// Be sure to set tipWidth wide enough for widest image
var tipWidth= 0;
var offX= 20; // how far from mouse to show tip
var offY= 12;
var tipFontFamily= "Verdana, arial, helvetica, sans-serif";
var tipFontSize= "8pt";
// set default text color and background color for tooltip here
// individual tooltips can have their own (set in messages arrays)
// but don't have to
var tipFontColor= "#000000";
var tipBgColor= "";
var tipBorderColor= "";
var tipBorderWidth= 0;
var tipBorderStyle= "none";
var tipPadding= 0;
 
// tooltip content goes here (image, description, optional bgColor, optional textcolor)
var messages = new Array();
// multi-dimensional arrays containing:
// image and text for tooltip
// optional: bgColor and color to be sent to tooltip
<?
$listing_query2 
tep_db_query($listing_split->sql_query);
while (
$listings tep_db_fetch_array($listing_query2)) { 
$wer=explode('"',tep_image(DIR_WS_IMAGES $listings['products_image'], $listings['products_name'] ,POPUP_IMAGE_WIDTHPOPUP_IMAGE_HEIGHT));
?>
messages[<?=$cnt?>] = new Array('<?=$wer[1]?>','<?=addslashes($listings['products_name'])?>',"#FFFFFF");
<?
$cnt
++;
}
?>
//////////////////// END OF CUSTOMIZATION AREA ///////////////////
 
// preload images that are to appear in tooltip
// from arrays above
if (document.images) {
var theImgs = new Array();
for (var i=0; i<messages.length; i++) {
theImgs[i] = new Image();
theImgs[i].src = messages[i][0];
}
}
 
// to layout image and text, 2-row table, image centered in top cell
// these go in var tip in doTooltip function
// startStr goes before image, midStr goes between image and text
var startStr = '<table width="' + tipWidth + '"><tr><td align="center" width="100%"><img src="';
var midStr = '" border="1"></td></tr><tr><td valign="top">';
var endStr = '</td></tr></table>';
 
////////////////////////////////////////////////////////////
// initTip - initialization for tooltip.
// Global variables for tooltip.
// Set styles for all but ns4.
// Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
var tooltip, tipcss;
function initTip() {
if (nodyn) return;
tooltip = (ns4)? document.tipDiv.document: (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
tipcss = (ns4)? document.tipDiv: tooltip.style;
if (ie4||ie5||ns5) { // ns4 would lose all this on rewrites
tipcss.width = tipWidth+"px";
tipcss.fontFamily = tipFontFamily;
tipcss.fontSize = tipFontSize;
tipcss.color = tipFontColor;
tipcss.backgroundColor = tipBgColor;
tipcss.borderColor = tipBorderColor;
tipcss.borderWidth = tipBorderWidth+"px";
tipcss.padding = tipPadding+"px";
tipcss.borderStyle = tipBorderStyle;
}
if (tooltip&&tipFollowMouse) {
if (ns4) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = trackMouse;
}
}
 
window.onload = initTip;
 
/////////////////////////////////////////////////
// doTooltip function
// Assembles content for tooltip and writes
// it to tipDiv
/////////////////////////////////////////////////
var t1,t2; // for setTimeouts
var tipOn = false; // check if over tooltip link
function doTooltip(evt,num) {
if (!tooltip) return;
if (t1) clearTimeout(t1); if (t2) clearTimeout(t2);
tipOn = true;
// set colors if included in messages array
if (messages[num][2]) var curBgColor = messages[num][2];
else curBgColor = tipBgColor;
if (messages[num][3]) var curFontColor = messages[num][3];
else curFontColor = tipFontColor;
if (ns4) {
var tip = '<table bgcolor="' + tipBorderColor + '" width="' + tipWidth + '" cellspacing="0" cellpadding="' + tipBorderWidth + '" border="0"><tr><td><table bgcolor="' + curBgColor + '" width="100%" cellspacing="0" cellpadding="' + tipPadding + '" border="0"><tr><td>'+ startStr + messages[num][0] + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; background:#FFFFFF; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr + '</td></tr></table></td></tr></table>';
 
tooltip.write(tip);
tooltip.close();
} else if (ie4||ie5||ns5) {
var tip = '<table bgcolor="0" bgcolor="#FFFFFF"><tr><td>' + startStr + messages[num][0] + midStr + '<span style="font-family:' + tipFontFamily + '; background:#000000; font-size:' + tipFontSize + '; color:#FFFFFF;">' + messages[num][1] + '</span>' + endStr + '</tr></td></table>';
tipcss.backgroundColor = curBgColor;
tooltip.innerHTML = tip;
}
if (!tipFollowMouse) positionTip(evt);
else t1=setTimeout("tipcss.visibility='visible'",100);
}
 
var mouseX, mouseY;
function trackMouse(evt) {
mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
if (tipOn) positionTip(evt);
}
 
/////////////////////////////////////////////////////////////
// positionTip function
// If tipFollowMouse set false, so trackMouse function
// not being used, get position of mouseover event.
// Calculations use mouseover event position,
// offset amounts and tooltip width to position
// tooltip within window.
/////////////////////////////////////////////////////////////
function positionTip(evt) {
if (!tipFollowMouse) {
mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
}
// tooltip width and height
var tpWd = (ns4)? tooltip.width: (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
var tpHt = (ns4)? tooltip.height: (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
// document area in view (subtract scrollbar width for ns)
var winWd = (ns4||ns5)? window.innerWidth-20+window.pageXOffset: document.body.clientWidth+document.body.scrollLeft;
var winHt = (ns4||ns5)? window.innerHeight-20+window.pageYOffset: document.body.clientHeight+document.body.scrollTop;
// check mouse position against tip and window dimensions
// and position the tooltip
if ((mouseX+offX+tpWd)>winWd)
tipcss.left = (ns4)? mouseX-(tpWd+offX): mouseX-(tpWd+offX)+"px";
else tipcss.left = (ns4)? mouseX+offX: mouseX+offX+"px";
if ((mouseY+offY+tpHt)>winHt)
tipcss.top = (ns4)? winHt-(tpHt+offY): winHt-(tpHt+offY)+"px";
else tipcss.top = (ns4)? mouseY+offY: mouseY+offY+"px";
if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
}
 
function hideTip() {
if (!tooltip) return;
t2=setTimeout("tipcss.visibility='hidden'",100);
tipOn = false;
}
 
//-->
</script>
<?
while ($listing tep_db_fetch_array($listing_query)) {
 
$lc_align 'center';
$lc_text '<table cellpadding="2" cellspacing="0" border="0">' "\r\n";
 
foreach (
$column_list as $column) {
switch(
$column) {
 
// Row: Products model
case 'PRODUCT_LIST_MODEL':
$lc_text .= ' <tr>' "\r\n"
' <td align="center"></td>' "\r\n"
' </tr>' "\r\n";
break;
// Row: Product's image
case 'PRODUCT_LIST_IMAGE':
$lc_text .= ' <tr>' "\r\n"
' <td align="center" height="170" valign="bottom"><div class="linephoto"><a href="' tep_href_link(FILENAME_PRODUCT_INFO, (isset($_GET['manufacturers_id']) ? 'manufacturers_id=' $_GET['manufacturers_id'] : ($cPath 'cPath=' $cPath '')) . '&products_id=' $listing['products_id']) . '" onmouseover="doTooltip(event,'.($rows-1).')" onmouseout="hideTip()">' tep_image(DIR_WS_IMAGES $listing['products_image'], $listing['Aproducts_name'], SMALL_IMAGE_WIDTHSMALL_IMAGE_HEIGHT) . '</a></div></td>' "\r\n"
' </tr>' "\r\n";
break;
 
// Row: Product's name
case 'PRODUCT_LIST_NAME':
$lc_text .= ' <tr>' "\r\n"
' <td align="center" height="30" valign="top"><div class="TextHome"><a href="' tep_href_link(FILENAME_PRODUCT_INFO, (isset($_GET['manufacturers_id']) ? 'manufacturers_id=' $_GET['manufacturers_id'] : ($cPath 'cPath=' $cPath '')) . '&products_id=' $listing['products_id']) . '">' $listing['products_name'] . '</a><div></td>' "\r\n"
' </tr>' "\r\n";
break;
 
// Row: Manufacturer's name
case 'PRODUCT_LIST_MANUFACTURER':
$lc_text .= ' <tr>' "\r\n"
' <td align="center"></td>' "\r\n"
' </tr>' "\r\n";
break;
 
// Row: Price
case 'PRODUCT_LIST_PRICE':
if (
tep_not_null($listing['specials_new_products_price'])) {
$lc_text .= ' <tr>' "\r\n"
' <td align="center"></td>' "\r\n"
' </tr>' "\r\n";
} else {
$lc_text .= ' <tr>' "\r\n"
' <td align="center"></td>' "\r\n"
' </tr>' "\r\n";
}
break;
 
// Row: Product's quantity
case 'PRODUCT_LIST_QUANTITY':
$lc_text .= ' <tr>' "\r\n"
' <td align="center"></td>' "\r\n"
' </tr>' "\r\n";
break;
 
// Row: Product's weight
case 'PRODUCT_LIST_WEIGHT':
$lc_text .= ' <tr>' "\r\n"
' <td align="center"></td>' "\r\n"
' </tr>' "\r\n";
break;
// Row: Buy now button
case 'PRODUCT_LIST_BUY_NOW':
$lc_text .= ' <tr>' "\r\n"
' <td align="center"></td>' "\r\n"
' </tr>' "\r\n";
break;
}
}
 
$lc_text .= '</table>' "\r\n";
 
$list_box_contents[$row][$col] = array(
'align' => $lc_align,
'params' => 'width="'round(100/PRODUCT_LIST_COLUMNS) .'%" class="productListing-data"',
'text' => $lc_text
);
 
$col ++;
if (
$col > (PRODUCT_LIST_COLUMNS-1)) {
$col 0;
$row ++;
}
}
 
while (
$col != && sizeof($list_box_contents[$row]) < PRODUCT_LIST_COLUMNS) {
$list_box_contents[$row][$col] = array(
'align' => 'center',
'params' => 'width="'round(100/PRODUCT_LIST_COLUMNS) .'%"',
'text' => '&nbsp;'
);
 
$col ++;
}
 
new 
productListingBox($list_box_contents);
} else {
$list_box_contents = array();
$list_box_contents[0] = array('params' => 'class="productListing-odd"');
$list_box_contents[0][] = array('params' => 'class="productListing-data"',
'text' => TEXT_NO_PRODUCTS);
new 
productListingBox($list_box_contents);
}
if ( (
$listing_split->number_of_rows 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
<td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE ' ' $listing_split->display_links(MAX_DISPLAY_PAGE_LINKStep_get_all_get_params(array('page''info''x''y'))); ?></td>
</tr>
</table>
<?php
}
?>
<div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100"></div>
------------------------------------------------------------------------------

Sorry about my poor English.

Thank you very much in advance
Attached Images
File Type: jpg tooltip-A.jpg (31.0 KB, 2 views)
File Type: jpg tooltip-B.jpg (30.3 KB, 2 views)

Last edited by duarte300; 07-13-2010 at 01:17 PM..
duarte300 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-13-2010, 01:11 PM Re: Tooltip in grid/columns layout, doesn't show over all images
Junior Talker

Posts: 2
Name: Leonardo Duarte
Trades: 0
I forgot to add,

The relevant code I think its the Javascript and ..." onmouseover="doTooltip(event,'.($rows-1).')" onmouseout="hideTip() "...

I already changed for " onmouseover="doTooltip(event,'.($col).')" onmouseout="hideTip() " but it won't work either. In this way it only shows the correct tooltip in the first horizontal row. In the second and third rows it repeats the same tooltip from the first row.

I also would like to know if it is possible to add the following to this code and how? (is useful for reducing the original image):
POPUP_IMAGE_WIDTH, POPUP_IMAGE_HEIGHT

To:

onmouseover="doTooltip(event,\'images/' .$listing['products_image'].'\')"

Like this, but it won't work, maybe I am missing some ponctuation:

onmouseover="doTooltip(event,\'images/' .$listing['products_image'], POPUP_IMAGE_WIDTH, POPUP_IMAGE_HEIGHT .'\')"

Thanks

Last edited by duarte300; 07-13-2010 at 01:15 PM..
duarte300 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Tooltip in grid/columns layout, doesn't show over all images
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31481 seconds with 13 queries