Note: This version of the clueTip plugin is no longer being supported. Please visit the clueTip project page for the most recent version. Also, the demo page has been moved.
This is a demo page for the new clueTip — a jQuery-based, AJAX-powered tooltip developed by Karl Swedberg. The clueTip plug-in was inspired by Cody Lindley's jTip script. Many feature ideas were provided by Shelane Enos. Glen Lipka and Jörn Zaefferer provided expert advice. Jonathan Chaffer helped a lot, but eschewed the co-author designation out of sheer modesty.
This page uses the jTip style for the clueTips.
The clueTip plug-in allows you to easily set a link to show a "tooltip" of sorts when the user's mouse hovers over the link. If the link includes a title attribute, its text becomes the heading of the clueTip. The contents of the clueTip can come from one of these sources:
The clueTip offers smart positioning:
The clueTip takes advantage of Brian Cherne's fantastic hoverIntent plugin if it's available. (Just include it in a <script> tag if you want the clueTip to use it.)
The clueTip comes with the following options:
width: default is 275local: default is false; set to true to use an element on the current page for the contents of the clueTip.
hideLocal: default is true. If the local option is set to true, this one determines whether local content to be shown in clueTip should be hidden at its original location.
attribute: default is 'rel'; set it to some other attribute of the link to designate that attribute as the one that refers to the clueTip's contenttitleAttribute: default is 'title'; set it to another attribute to use its text for the clueTip's titlesplitTitle: default is an empty string; set to a character such as "|" to split the title attribute of a link into the clueTip heading (the first string, before the first delimiter character) and individual clueTip body divs (subsequent strings).hoverClass: default is an empty string; set to the name of the class to add that class to the link on hoverwaitImage: default is 'wait.gif'; not implemented yetsticky: default is false; set to true if you want the clueTip to remain open when you "mouse out" of the link. This option also places a "close" link on the clueTip itself. activation: default is 'hover'; set to 'toggle' to force the user to click the element in order to activate the clueTip.closePosition: default is 'top'; set to 'bottom' to put the 'close' link at the bottom of the clueTip. Additional formatting can be applied to a#cluetip-close in the style sheet.closeText: default is 'Close'; set it to something else if you want totruncate: default is 0, which means there will be no truncation; set it to some number to truncate the clueTip's contents to n characterspngFix: default is true; fixes png transparency for the clueTip in IE<=6. change to false to disable it.hoverIntent: default is true; if jquery.hoverintent.js plugin is included in <head>, .hoverIntent() will be used instead of .hover()ajaxProcess: default is:
function(data) {data = $(data).not('style, meta, link, script, title');
return data;
}
This default value strips out tags from the <head> of an HTML page that is being pulled into a clueTip via "AHAH."ajaxSettings: default is {dataType: 'html'}. You can use any argument here that you would use in $.ajax(). To use the plug-in, you'll need to include 4 JavaScript files in your web page's <head>, like so:
<script src="scripts/jquery.js" type="text/javascript"></script>
<script src="scripts/jquery.dimensions.js" type="text/javascript"></script>
<script src="scripts/jquery.cluetip.js" type="text/javascript"></script>
<script src="scripts/your-custom-file.js" type="text/javascript"></script>
As you can see, the clueTip depends on jquery.js and jquery.dimensions.js to function properly.
If you would like to use clueTip in conjunction with the hoverIntent plugin, you will need to reference that plugin as well.
When you want to add a clueTip to a link, type the content's location in an attribute:
<a href="foo.htm" rel="bar.htm">Link to foo.htm; show bar.htm in the clueTip</a>
The rel attribute is used by default, but you can change it to any other attribute you wish, like so: $('a').cluetip({attribute: 'name'}). Now you can write the HTML like this:
<a href="foo.htm" name="bar.htm">Link to foo.htm; show bar.htm in the clueTip</a>
The href attribute is used for the actual link. If the rel (or your custom) attribute is the same as the href attribute, hovering over the link will turn the cursor into a question mark. Also, the link will become "dead," meaning that nothing will happen if the user clicks it:
<a href="foo.htm" rel="foo.htm">Clicking me will get you nowhere</a>
Otherwise, clicking on the link will take the user to the URL in the href, as expected.
Here are some examples of how you can add a clueTip to your page. Note that since all of the clueTips here use the alternate "jTip" style, they all have at least two options set, arrows: true and dropShadow: false. If you know you're always going to use the jTip style, you can change these options in jquery.cluetip.js instead:
$('a.basic').cluetip({arrows: true, dropShadow: false});. This is the simplest example there is: <a class="basic" href="ajax.htm" rel="ajax.htm">$('a.custom-width').cluetip({width: '200px', arrows: true, dropShadow: false}); This tip has a custom width and title: <a class="custom-width" href="ajax3.htm" title="Fancy Title!" rel="ajax3.htm">$('h4').cluetip({attribute: 'id', hoverClass: 'highlight', arrows: true, dropShadow: false});
$('#sticky').cluetip({sticky: true, arrows: true, dropShadow: false}); This is a sticky clueTip: <a id="sticky" href="ajax6.htm" rel="ajax6.htm">. It won't close until you close it. Or until you hover over another clue-tipped link.$('a.load-local').cluetip({local:true, arrows: true, dropShadow: false}); This one uses local content from a hidden div element: <a class="load-local" href="#loadme" rel="#loadme">$('#examples a:eq(4)').cluetip({
hoverClass: 'highlight',
sticky: true,
closePosition: 'bottom',
closeText: '<img src="styles/cross.png" alt="" />'
truncate: 60,
arrows: true,
dropShadow: false
});
If you click this link — <a href="http://www.learningjquery.com" title="about this link:" rel="ajax6.htm"> — you'll be directed to learningjquery.com$('#clickme').cluetip({activation: 'click', arrows: true, dropShadow: false}); This one won't show the clueTip unless you click it <a href="ajax5.htm" rel="ajax5.htm" title="active ingredients">You can style your clueTips any way you want. Here are the alternate styles that mimic Cody Lindley's jTip plugin:
.clue-right {
background-image: url(arrowleft.gif);
background-repeat: no-repeat;
padding-left: 10px;
}
.clue-left {
background-image: url(arrowright.gif);
background-repeat: no-repeat;
padding-right: 10px;
}
#cluetip-outer {
border: 2px solid #ccc;
position: relative;
background: #fff;
}
h3#cluetip-title {
margin: 0 0 5px;
padding: 2px 5px;
font-size: 16px;
font-weight: normal;
background-color: #ccc;
color: #333;
}
span#cluetip-close {
text-align: right;
margin: 0 5px 5px;
color: #900;
}
#cluetip-close img {
border: 0;
}
this is the local content to load when the 'local' parameter is set to true. Currently it only works with an id selector.
Here is a list of bugs and features I've been working on:
$.ajax().ClueTip
Dependencies