From fe931940568af4fd3159020d836b7b4b33de9752 Mon Sep 17 00:00:00 2001
From: Regis Houssin <regis@dolibarr.fr>
Date: Fri, 22 Oct 2010 08:06:41 +0000
Subject: [PATCH] New: use jQuery tooltip

---
 htdocs/core/class/html.form.class.php | 14 ++++++++++++--
 htdocs/main.inc.php                   | 15 +++++++++++++--
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index e6aa1832ddb..1be108c2b44 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -150,8 +150,8 @@ class Form
 
         // Sanitize tooltip
         $htmltext=str_replace("\\","\\\\",$htmltext);
-        $htmltext=str_replace("'","\'",$htmltext);
-        $htmltext=str_replace("&#039;","\'",$htmltext);
+        //$htmltext=str_replace("'","\'",$htmltext);
+        //$htmltext=str_replace("&#039;","\'",$htmltext);
         $htmltext=str_replace("\r","",$htmltext);
         $htmltext=str_replace("<br>\n","<br>",$htmltext);
         $htmltext=str_replace("\n","",$htmltext);
@@ -159,6 +159,7 @@ class Form
         if ($conf->use_javascript_ajax)
         {
         	$htmltext=str_replace('"',"&quot;",$htmltext);
+        	/*
         	if ($tooltipon==1 || $tooltipon==3)
         	{
         		$paramfortooltiptext.=' onmouseover="showtip(\''.$htmltext.'\')"';
@@ -169,6 +170,15 @@ class Form
             	$paramfortooltippicto.=' onmouseover="showtip(\''.$htmltext.'\')"';
             	$paramfortooltippicto.=' onMouseout="hidetip()"';
             }
+            */
+        	if ($tooltipon==1 || $tooltipon==3)
+        	{
+        		$paramfortooltiptext.=' title="'.$htmltext.'"';
+            }
+            if ($tooltipon==2 || $tooltipon==3)
+            {
+            	$paramfortooltippicto.=' title="'.$htmltext.'"';
+            }
         }
         
         $s="";
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 0184642ae52..5e41a026aea 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -818,6 +818,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
             $jquerytheme = 'smoothness';
             if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME;
             print '<link rel="stylesheet" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui-1.8.5.custom.css" type="text/css" />'."\n";
+            print '<link rel="stylesheet" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/tooltip/jquery.tooltip.css" type="text/css" />'."\n";
         }
 
         print '<!-- Includes for Dolibarr, modules or specific pages-->'."\n";
@@ -954,7 +955,17 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
 	}
 
     print "\n".'<!-- Start top horizontal menu '.$top_menu.' -->'."\n";
-    print '<div class="tmenu">'."\n";
+    print '<script type="text/javascript">
+    			jQuery(function() {
+    				jQuery("#tmenu_tooltip *").tooltip({
+    					track: true, 
+    					delay: 0,
+    					showURL: false,
+    					positionLeft: true
+					});
+    			});
+    		</script>';
+    print '<div id="tmenu_tooltip" class="tmenu">'."\n";
 
     // Show menu
     $menutop = new MenuTop($db);
@@ -971,7 +982,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
 			{
 				//$mc = new ActionsMulticompany($db);
 				$entitytext = img_object('', 'globe','entity');
-				$entityhtmltext = 'text';
+				$entityhtmltext = 'EntityName';
 				print $html->textwithtooltip('',$entityhtmltext,2,1,$entitytext);
 				//$select_entity = '<div class="loginSelectEntity">'.$mc->select_entities($conf->entity).'</div>';
 				//if ($mc->numEntity >= 1) print $select_entity;
-- 
GitLab