A tooltips is a piece of text that pops up when you hover the mouse over a region on a website. If you use the Joomla! back end, for example, tooltips are used to help explain the action of different parameters, as shown in the screenshot below:

A tooltips is a piece of text that pops up when you hover the mouse over a region on a website. If you use the Joomla! back end, for example, tooltips are used to help explain the action of different parameters, as shown in the screenshot below:

Line 7:

Line 5:

Tooltips are a great way to give the user access to information without using up space on the screen. You can use basic tooltips just by adding a "title" attribute to a tag. However, this doesn't give you the option to style the tooltips. With Joomla! version 1.5, it is very easy to add styled tooltips to your site. This tutorial will show you how. <blockquote>''Note: If you are converting old code, make sure it doesn't use the prototype.js file. That file will keep the tooltips from working.''</blockquote>

Tooltips are a great way to give the user access to information without using up space on the screen. You can use basic tooltips just by adding a "title" attribute to a tag. However, this doesn't give you the option to style the tooltips. With Joomla! version 1.5, it is very easy to add styled tooltips to your site. This tutorial will show you how. <blockquote>''Note: If you are converting old code, make sure it doesn't use the prototype.js file. That file will keep the tooltips from working.''</blockquote>

−

===Activate Tooltip Behavior===

+

== Activate Tooltip Behavior ==

To start, you must activate the tooltip behavior. This is done with the following line of code:

To start, you must activate the tooltip behavior. This is done with the following line of code:

<source lang="php">

<source lang="php">

Line 23:

Line 21:

This allows tooltips to function, as outlined below.

This allows tooltips to function, as outlined below.

−

===Create a Tooltip with the JHTML::tooltip Method===

+

== Create a Tooltip with the JHTML::tooltip Method ==

−

One way to create a tooltip is using the JHTML::tooltip method. The API documentation is available at [http://api.joomla.org/Joomla-Framework/HTML/JHTML.html#tooltip http://api.joomla.org/Joomla-Framework/HTML/JHTML.html#tooltip]. The method definition is shown below.

+

One way to create a tooltip is using the JHTML::tooltip method. The API documentation is available at [http://api.joomla.org/1.5/Joomla-Framework/HTML/JHTML.html#tooltip http://api.joomla.org/1.5/Joomla-Framework/HTML/JHTML.html#tooltip]. The method definition is shown below.

The above will make a tooltip using the default "tooltip.png" image, as shown below.

+

The above will make a tooltip using the default "tooltip.png" image, as shown below.[[Image:Tooltip_tutorial_example_screenshot_20090208.png|center|frame]]Clicking the image will take you to <tt>http://www.joomla.org</tt>, since that is the "$href" argument. The HTML source for this tooltip is as follows:

Clicking the image will take you to <tt>http://www.joola.org</tt>, since that is the "$href" argument.

+

<blockquote>''Internet Explorer Bug: As shown above, when you use the JHTML::tooltip method to create an image tooltip, it creates an "alt" attribute with the value "Tooltip". The "alt" attribute is used in cases where the image file cannot be found or for accessibility (for example, for blind users). Internet Explorer automatically -- and incorrectly -- displays the "alt" attribute as a tooltip. This means that image tooltips created by JHTML::tooltip (like the example above) will display with two tooltips when viewed with Internet Explorer, as shown below.''</blockquote>

+

[[Image:Tooltip_tutorial_ie7bug_20090301.png|center|frame]]

+

<blockquote>''You can avoid this problem either by using text tooltips or by not using this method for image tooltips. Instead, just enter the HTML manually and set the "alt" attribute to an empty string (alt="").''</blockquote>

This code is almost the same as above except the image will not be a link (because the "$href" argument is omitted).

This code is almost the same as above except the image will not be a link (because the "$href" argument is omitted).

Line 59:

Line 63:

Note that specifying the "$text" parameter will override any image you have passed to tooltip.

Note that specifying the "$text" parameter will override any image you have passed to tooltip.

−

===Create a Tooltip Using a CSS Class Name===

+

== Create a Tooltip Using a CSS Class Name ==

If we look at the HTML page source generated by the <code>JHTML::tooltip</code> function above, here is what we see:

If we look at the HTML page source generated by the <code>JHTML::tooltip</code> function above, here is what we see:

style="text-decoration: none; color: #333;">Hover on this text to see the tooltip</span>

+

title="Text Tooltip Title::This is a tooltip attached to text"

+

style="text-decoration: none; color: #333;">

+

Hover on this text to see the tooltip</span>

</source>

</source>

This function generates an HTML "span" tag with the classes "editlinktip" and "hasTip" and an attribute called "title". Notice that the the "title" attribute has two parts, <code><tooltip title>::<tooltip text></code> (for example, "Tooltip Title::This is the tooltip text"). You can create a tooltip with only text or with only a title. The title has implications for styling, as we'll see below.

This function generates an HTML "span" tag with the classes "editlinktip" and "hasTip" and an attribute called "title". Notice that the the "title" attribute has two parts, <code><tooltip title>::<tooltip text></code> (for example, "Tooltip Title::This is the tooltip text"). You can create a tooltip with only text or with only a title. The title has implications for styling, as we'll see below.

Line 69:

Line 75:

The Javascript inserted by the <code>JHTML::('behavior_tooltip')</code> command we entered earlier picks up this tag based on the class called "hasTip". So, a second way of creating a tooltip is to simply create a tag with a class called "hasTip" and an attribute of "title". For example, this code

The Javascript inserted by the <code>JHTML::('behavior_tooltip')</code> command we entered earlier picks up this tag based on the class called "hasTip". So, a second way of creating a tooltip is to simply create a tag with a class called "hasTip" and an attribute of "title". For example, this code

will produce exactly the same effect as the <code>JHTML::tootip()</code> example above.

+

will produce exactly the same effect as the <code>JHTML::tooltip()</code> example above.

−

===Adding CSS Styling to the Tooltip===

+

== Adding CSS Styling to the Tooltip ==

The default tooltips, whether using the JHTML::tooltip method or class method, use the following three CSS classes: <tt>.tool-tip</tt>, <tt>.tool-title</tt>, and <tt>.tool-text</tt>.

The default tooltips, whether using the JHTML::tooltip method or class method, use the following three CSS classes: <tt>.tool-tip</tt>, <tt>.tool-title</tt>, and <tt>.tool-text</tt>.

Line 105:

Line 112:

</source>

</source>

−

If you have a custom CSS file, copy this code and alter it to your liking. Note that the <tt>.tool-title</tt> class uses by default the "selector-arrow.png" image. This is what gives the outline of the tooltip the little pointer in the upper left of the tooltip box. If you leave out a title in your tooltip, you will just get a rectangle, without the pointer.

+

{{version|1.5,2.5}}

+

== Adding CSS Styling to the Tooltip Joomla 2.5==

+

The default tooltips, whether using the JHTML::tooltip method or class method, use the following three CSS classes: <tt>.tip</tt>, <tt>.tip-title</tt>, and <tt>.tip-text</tt> plus a wrapper class <tt>.tip-wrap</tt>.

−

===Customizing Your Yooltips===

+

Here are the default styles.

+

<source lang="css">

+

/* Tooltips */

+

.tip-wrap{

+

z-index: 10000;

+

}

+

.tip {

+

float: left;

+

background: #ffc;

+

border: 1px solid #D4D5AA;

+

padding: 5px;

+

max-width: 200px;

+

}

+

+

.tip-title {

+

padding: 0;

+

margin: 0;

+

font-size: 100%;

+

font-weight: bold;

+

margin-top: -15px;

+

padding-top: 15px;

+

padding-bottom: 5px;

+

background: url(../images/selector-arrow.png) no-repeat;

+

}

+

+

.tip-text {

+

font-size: 100%;

+

margin: 0;

+

}

+

</source>

+

+

If you have a custom CSS file, copy this code and alter it to your liking. Note that the <tt>.tool-title</tt> (<tt>.tip-title</tt> Joomla 2.5) class uses by default the "selector-arrow.png" image. This is what gives the outline of the tooltip the little pointer in the upper left of the tooltip box. If you leave out a title in your tooltip, you will just get a rectangle, without the pointer.

+

+

== Customizing Your Tooltips ==

Ok, now it's time to have some fun. The <code>JHTML::_('behavior.tooltip')</code> can take two optional parameters. The first parameter is the name of the CSS class that will be used to identify the tooltip. As we saw earlier, this defaults to "hasTip". The second optional parameter is an array of parameters that you can use to fine-tune the tooltip functionality. These are explained below.

Ok, now it's time to have some fun. The <code>JHTML::_('behavior.tooltip')</code> can take two optional parameters. The first parameter is the name of the CSS class that will be used to identify the tooltip. As we saw earlier, this defaults to "hasTip". The second optional parameter is an array of parameters that you can use to fine-tune the tooltip functionality. These are explained below.

* '''maxTitleChars:''' The maximum length of the title (the part of the "title" attribute before the "::")

* '''maxTitleChars:''' The maximum length of the title (the part of the "title" attribute before the "::")

Line 117:

Line 159:

In the next section, we'll show how to use these parameters with some examples.

In the next section, we'll show how to use these parameters with some examples.

−

===Tooltip With Different Classes===

+

== Tooltip With Different Classes ==

In this example, we will create a tooltip using different selector and tooltip styling classes. Why might we want to do this? One reason would be if we had different types of tooltips and we wanted to style them differently.

In this example, we will create a tooltip using different selector and tooltip styling classes. Why might we want to do this? One reason would be if we had different types of tooltips and we wanted to style them differently.

Here is the code to create the tooltip Javascript function:

Here is the code to create the tooltip Javascript function:

<source lang="php">

<source lang="php">

−

$toolTipArray2 = array('className'=>'custom2');

+

$toolTipArray = array('className'=>'custom2');

JHTML::_('behavior.tooltip', '.hasTip2', $toolTipArray);

JHTML::_('behavior.tooltip', '.hasTip2', $toolTipArray);

</source>

</source>

Line 138:

Line 180:

<source lang="php">

<source lang="php">

$toolTipArray = array('className' => 'custom2', 'showDelay'=>'500',

$toolTipArray = array('className' => 'custom2', 'showDelay'=>'500',

−

'hideDelay'=>'500', 'fixed'=>'true',

+

'hideDelay'=>'500', 'fixed'=>true,

'onShow'=>"function(tip) {tip.effect('opacity',

'onShow'=>"function(tip) {tip.effect('opacity',

{duration: 500, wait: false}).start(0,1)}",

{duration: 500, wait: false}).start(0,1)}",

Line 147:

Line 189:

Again, we are building an array to pass to the <code>JHTML::_('behavior.tooltip')</code> function. Again, we are setting the "className" parameter to "custom2". We are also setting the "showDelay" and "hideDelay" parameters to 500 milliseconds (.5 seconds). So the tooltip will show only after the mouse has hovered for this amount of time.

Again, we are building an array to pass to the <code>JHTML::_('behavior.tooltip')</code> function. Again, we are setting the "className" parameter to "custom2". We are also setting the "showDelay" and "hideDelay" parameters to 500 milliseconds (.5 seconds). So the tooltip will show only after the mouse has hovered for this amount of time.

−

Notice that we are setting the parameter "fixed" to "true". This means that the tooltip will not move with the mouse. Instead, it will always show centered below the tooltip text or image.

+

Notice that we are setting the parameter "fixed" to "true" (without the quotes). This means that the tooltip will not move with the mouse. Instead, it will always show centered below the tooltip text or image.

−

Finally, the tricky part. We are creating functions to pass in to the "onShow" and "onHide" events. These functions cause the tooltip to fade in and fade out over the space of 500 milliseconds. These functions are based on sample code in the [http://demos111.mootools.net/Tips MooTools demo tutorial]. Click on the link called "js code" and look at the code for the "Tips2" demo. We have just taken the code from the initialize function and incorporated it into the "onShow" and "onHide" functions.

+

Finally, the tricky part. We are creating functions to pass in to the "onShow" and "onHide" events. These functions cause the tooltip to fade in and fade out over the space of 500 milliseconds. This is done by gradually varying the tooltip's CSS "opacity" style from "0" (completely transparent) to "1" (completely opaque). If we wanted the tooltip to be partially transparent, we could change these to <code>start(0,.8)</code> and <code>start(.8,0)</code>.

+

+

These functions are similar to the sample code in the [http://demos111.mootools.net/Tips MooTools demo tutorial]. Click on the link called "js code" and look at the code for the "Tips2" demo. We have just taken the code from the initialize function and incorporated it into the "onShow" and "onHide" functions.

The last line of code above creates the actual Javascript code in our Joomla! document. If we show the page and view source, we see the following:

The last line of code above creates the actual Javascript code in our Joomla! document. If we show the page and view source, we see the following:

Line 164:

Line 208:

So we can see the effect of the parameters that we passed to the <code>JHTML::_('behavior.tooltip')</code> method.

So we can see the effect of the parameters that we passed to the <code>JHTML::_('behavior.tooltip')</code> method.

−

===Using an External Javascript File===

+

=== offsets Parameter ===

+

<blockquote>''Note: The "offsets" parameter doesn't work in version 1.5.9 and earlier because of a bug. As of version 1.5.10 it should work as outlined below.''</blockquote>

+

You can control the x and y distance, in pixels, from the cursor to the tooltip using the "offsets" parameter. This parameter must be an array as shown in the example code below:

This will load your script into the document and make sure that the MooTools library is available.

This will load your script into the document and make sure that the MooTools library is available.

−

===Complete Code Example===

+

== Complete Code Example ==

Here is an example that incorporates all of the elements discussed in this tutorial. So you can see the code in action, we will create an override of the "mod_stats" Module and add our test code there. We will use the rhuk_milkyway template.

Here is an example that incorporates all of the elements discussed in this tutorial. So you can see the code in action, we will create an override of the "mod_stats" Module and add our test code there. We will use the rhuk_milkyway template.

This code is taken from the MooTools demo site referenced above. Notice that will operate on the "hasTip3" class and will use style classes starting with "custom3-". This also has the fade-in and fade-out functionality.

+

This code will operate on the "hasTip3" class and will use style classes starting with "custom3-". We are setting the x distance (from the cursor to the tooltip) to 20 pixels and the y distance to 30 pixels. This also has the fade-in and fade-out functionality, but the final "opacity" value is set to .8, meaning that the tooltip will be slightly transparent.

Finally, add this to the end of your "templates/rhuk_milkyway/css/template.css" file:

Finally, add this to the end of your "templates/rhuk_milkyway/css/template.css" file:

Line 297:

Line 358:

Notice that <tt>.custom2-title</tt> and <tt>.custom3-title</tt> classes do not have a background property. So these tooltips will be a box without the neat little arrow pointing at the mouse. If you wanted, you could create an image similar to "templates/system/images/selector-arrow.png" of the right color and add that as a background to these classes.

Notice that <tt>.custom2-title</tt> and <tt>.custom3-title</tt> classes do not have a background property. So these tooltips will be a box without the neat little arrow pointing at the mouse. If you wanted, you could create an image similar to "templates/system/images/selector-arrow.png" of the right color and add that as a background to these classes.

−

===Example Code Screenshots===

+

== Example Code Screenshots ==

Here are some screenshots taken from the sample code above. The first screenshot shows the modified "mod_stats" modules with our sample code.

Here are some screenshots taken from the sample code above. The first screenshot shows the modified "mod_stats" modules with our sample code.

[[Image:Screen_tooltip_example2_20090210.png|center|frame]]

[[Image:Screen_tooltip_example2_20090210.png|center|frame]]

Line 305:

Line 366:

[[Image:Screen_tooltip_example3_20090210.png|center|frame]]

[[Image:Screen_tooltip_example3_20090210.png|center|frame]]

−

===More Information===

+

== More Information ==

+

More information about the topics covered in this tutorial is available at the links below. Note that Joomla! version 1.5 uses MooTools version 1.11. The current version of MooTools is 1.2.

Latest revision as of 19:40, 25 August 2013

This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

A tooltips is a piece of text that pops up when you hover the mouse over a region on a website. If you use the Joomla! back end, for example, tooltips are used to help explain the action of different parameters, as shown in the screenshot below:

Tooltips are a great way to give the user access to information without using up space on the screen. You can use basic tooltips just by adding a "title" attribute to a tag. However, this doesn't give you the option to style the tooltips. With Joomla! version 1.5, it is very easy to add styled tooltips to your site. This tutorial will show you how.

Note: If you are converting old code, make sure it doesn't use the prototype.js file. That file will keep the tooltips from working.

Activate Tooltip Behavior

To start, you must activate the tooltip behavior. This is done with the following line of code:

JHTML::_('behavior.tooltip');

Note that you only put this line in once per file. A good place is right after the defined('_JEXEC') or die('Restricted access'); line. If you are curious about what this line does, it inserts the following JavaScript code in the heading of the HTML page:

The brackets mean the parameter is optional. The first parameter, "$tooltip", is the only required parameter. The equals specifies the default if you do not pass that parameter. For example, the image file 'tooltip.png' is the default image.

The following is a basic tooltip. Keep in mind that the image variable must be in reference to 'includes/js/ThemeOffice'. Use the prefix '../../../' to reference from the root of the Joomla installation.

JHTML::tooltip('This is the tooltip text','Tooltip title','tooltip.png','','http://www.joomla.org');

The above will make a tooltip using the default "tooltip.png" image, as shown below.

Clicking the image will take you to http://www.joomla.org, since that is the "$href" argument. The HTML source for this tooltip is as follows:

Internet Explorer Bug: As shown above, when you use the JHTML::tooltip method to create an image tooltip, it creates an "alt" attribute with the value "Tooltip". The "alt" attribute is used in cases where the image file cannot be found or for accessibility (for example, for blind users). Internet Explorer automatically -- and incorrectly -- displays the "alt" attribute as a tooltip. This means that image tooltips created by JHTML::tooltip (like the example above) will display with two tooltips when viewed with Internet Explorer, as shown below.

You can avoid this problem either by using text tooltips or by not using this method for image tooltips. Instead, just enter the HTML manually and set the "alt" attribute to an empty string (alt="").

This code is almost the same as above except the image will not be a link (because the "$href" argument is omitted).

JHTML::tooltip('This is the tooltip text','Tooltip title','tooltip.png','','',false);

A tooltip can be attached to an image or to text. For example, this code

echo JHTML::tooltip('This is a tooltip attached to text','Text Tooltip Title','','Hover on this text to see the tooltip');

will show a tooltip attached to text, as shown below.

Note that specifying the "$text" parameter will override any image you have passed to tooltip.

Create a Tooltip Using a CSS Class Name

If we look at the HTML page source generated by the JHTML::tooltip function above, here is what we see:

<spanclass="editlinktip hasTip"title="Text Tooltip Title::This is a tooltip attached to text"style="text-decoration: none; color: #333;">
Hover on this text to see the tooltip</span>

This function generates an HTML "span" tag with the classes "editlinktip" and "hasTip" and an attribute called "title". Notice that the the "title" attribute has two parts, <tooltip title>::<tooltip text> (for example, "Tooltip Title::This is the tooltip text"). You can create a tooltip with only text or with only a title. The title has implications for styling, as we'll see below.

The Javascript inserted by the JHTML::('behavior_tooltip') command we entered earlier picks up this tag based on the class called "hasTip". So, a second way of creating a tooltip is to simply create a tag with a class called "hasTip" and an attribute of "title". For example, this code

<spanclass="hasTip"title="Text Tooltip Title::This is a tooltip attached to text">
Hover on this text to see the tooltip</span>

will produce exactly the same effect as the JHTML::tooltip() example above.

Adding CSS Styling to the Tooltip

The default tooltips, whether using the JHTML::tooltip method or class method, use the following three CSS classes: .tool-tip, .tool-title, and .tool-text.

If you have a custom CSS file, copy this code and alter it to your liking. Note that the .tool-title (.tip-title Joomla 2.5) class uses by default the "selector-arrow.png" image. This is what gives the outline of the tooltip the little pointer in the upper left of the tooltip box. If you leave out a title in your tooltip, you will just get a rectangle, without the pointer.

Customizing Your Tooltips

Ok, now it's time to have some fun. The JHTML::_('behavior.tooltip') can take two optional parameters. The first parameter is the name of the CSS class that will be used to identify the tooltip. As we saw earlier, this defaults to "hasTip". The second optional parameter is an array of parameters that you can use to fine-tune the tooltip functionality. These are explained below.

maxTitleChars: The maximum length of the title (the part of the "title" attribute before the "::")

showDelay, hideDelay: The time to delay showing or hiding the tooltip, in milliseconds. Default is 100.

className: The first part of the class name used to style the actual tooltip. The default, as we saw, is "tool", and the full class names by default are "tool-tip", "tool-title', and "tool-text". So, for example, if we set this to "custom", we would style the classes "custom-tip", "custom-title", and "custom-text".

fixed: Whether or not to have the tooltip move with the mouse. If set to "true", the tooltip will be centered below the text or image. If set to "false", the tooltip will move with the mouse. Default is "false".

onShow, onHide: Functions to call for the onShow and onHide events. We'll see an example below where we can use these to create a fade-in and fade-out for the tooltip.

In the next section, we'll show how to use these parameters with some examples.

Tooltip With Different Classes

In this example, we will create a tooltip using different selector and tooltip styling classes. Why might we want to do this? One reason would be if we had different types of tooltips and we wanted to style them differently.

In this code, we are creating an array with just one element -- to set the "className" parameter to "custom2". This means that, to style these tooltips, we would use the classes custom2-tip, custom2-title, and custom2-text. Then we call the method with the arguments ".hasTip2" and the array "$toolTipArray". It can be a little confusing, because we have two CSS classes at work here. The class ".hasTip2" is used in the HTML tag. That is how the Javascript program identifies the tooltips to operate on. The class "custom2" is used as the first part of the three CSS classes to use to style the actual tooltip itself.

Since we set the class to "hasTip2", this tag will be processed by the new version of the tooltip program. So, if we use both the default tooltip ("hasTip" class) and the new tooltip ("hasTip2" class) in the same page, we can style them differently using "tool-" styles for the default and "custom2-" styles for the "hasTip2" tooltips.

Again, we are building an array to pass to the JHTML::_('behavior.tooltip') function. Again, we are setting the "className" parameter to "custom2". We are also setting the "showDelay" and "hideDelay" parameters to 500 milliseconds (.5 seconds). So the tooltip will show only after the mouse has hovered for this amount of time.

Notice that we are setting the parameter "fixed" to "true" (without the quotes). This means that the tooltip will not move with the mouse. Instead, it will always show centered below the tooltip text or image.

Finally, the tricky part. We are creating functions to pass in to the "onShow" and "onHide" events. These functions cause the tooltip to fade in and fade out over the space of 500 milliseconds. This is done by gradually varying the tooltip's CSS "opacity" style from "0" (completely transparent) to "1" (completely opaque). If we wanted the tooltip to be partially transparent, we could change these to start(0,.8) and start(.8,0).

These functions are similar to the sample code in the MooTools demo tutorial. Click on the link called "js code" and look at the code for the "Tips2" demo. We have just taken the code from the initialize function and incorporated it into the "onShow" and "onHide" functions.

The last line of code above creates the actual Javascript code in our Joomla! document. If we show the page and view source, we see the following:

Use the JHTML::script function to add this script to your document. For example:

$filename='testtooltip.js';// this file is used for class="hasTip3" titles$path='templates/rhuk_milkyway/js/';// path to the file// true means MooTools will load if it is not already loaded
JHTML::script($filename,$path,true);

This will load your script into the document and make sure that the MooTools library is available.

Complete Code Example

Here is an example that incorporates all of the elements discussed in this tutorial. So you can see the code in action, we will create an override of the "mod_stats" Module and add our test code there. We will use the rhuk_milkyway template.

To set up the template override, create a folder called "templates/rhuk_milkyway/html/mod_stats" and copy the file "modules/mod_stats/tmpl/default.php" to this new folder.

After line 2 of this file (defined('_JEXEC') or die('Restricted access');), insert the following:

The first two examples using the JHTML::tooltip function to create the tooltip HTML code.

The third example shows an "a" tag with a tooltip. This illustrates that you can put tooltips on most HTML tags, not just "span" tags. Again, it is using the "hasTip" class, so it will be controlled by the Javascript above called with the ".hasTip" argument and will be styled with the default "tool-" styles.

The fourth example shows a "span" tag using the "hasTip2" class. So it will be styled using the "custom2-" classes and will have the "showDelay" and "hideDelay" of 500 milliseconds and have "fixed" equal to "true" (so the tip will not move with the mouse). Also, it uses the special fade-in and fade-out effects.

The last example will use the Javascript code from the external file, shown below.

Now, some more coding. Create a JavaScript file called "testtooltip.js" and save it into the folder "templates/rhuk_milkyway/js":

This code will operate on the "hasTip3" class and will use style classes starting with "custom3-". We are setting the x distance (from the cursor to the tooltip) to 20 pixels and the y distance to 30 pixels. This also has the fade-in and fade-out functionality, but the final "opacity" value is set to .8, meaning that the tooltip will be slightly transparent.

Finally, add this to the end of your "templates/rhuk_milkyway/css/template.css" file:

Here we are just adding different colors for the "custom2-" and "custom3-" styles so you can see the effect of the different tooltip code.

Notice that .custom2-title and .custom3-title classes do not have a background property. So these tooltips will be a box without the neat little arrow pointing at the mouse. If you wanted, you could create an image similar to "templates/system/images/selector-arrow.png" of the right color and add that as a background to these classes.

Example Code Screenshots

Here are some screenshots taken from the sample code above. The first screenshot shows the modified "mod_stats" modules with our sample code.

The screenshot below shows the fade-in effect for the ".hasTip2" tooltip. Notice also that the tooltip is centered below the text. This is the effect of setting "fixed" equal to "true".

The last screenshot shows the different styling for the ".hasTip3" tooltip, based on the "custom3-" CSS class styles.

More Information

More information about the topics covered in this tutorial is available at the links below. Note that Joomla! version 1.5 uses MooTools version 1.11. The current version of MooTools is 1.2.