<link href="css/jatt.css" rel="stylesheet"> <script src="js/jquery.min.js"></script> <!-- minimum jQuery v1.7+ --> <script src="js/jquery.jatt.js"></script> <script> $(function(){ $.jatt(); }); </script>
basic tip (a) | <a class="tooltip " href="#" title="Tooltip (a) Content">basic tip (a))</a> |
External page (a) | <a class="tooltip preload " href="demo/ajax-content.htm #target span">External page (a)</span> |
Object on page (div) | <div class="tooltip " rel="#tip1">Object on page (div)</div> <div id="tip1" style="display:none">Hi</div> |
paragraph (p) | <p class="tooltip " title="Tooltip (p) Content">paragraph (p)</p> |
<img class="tooltip " src="demo/popup.gif" title="Tooltip (img) Content" > | |
span (span) | <span class="tooltip " title="Tooltip (span) Content">span (span)</span> |
<input class="tooltip sticky " style="width:50px;" title="Tooltip (input)"> |
<a class="preview " href="URL to full size image" title="Google's Logo"><img src="URL to image thumbnail"></a> |
LMYC | <a class="screenshot " href="http://www.guildportal.com/Guild.aspx?GuildID=194525&TabID=1643295" title="<center>Loch Modan Yacht Club</center>" rel="Website_Screenshot.jpg">LMYC</a> |
<a class="screenshot " href="http://www.google.com" title="<center>Google</center>" rel="#">Google</a> |
$(function(){ $.jatt({ // options that can be modified by metadata direction : 'n', // direction of tooltip followMouse : true, // tooltip follows mouse movement content : 'title', // attribute containing tooltip text speed : 300, // tooltip fadein speed local : false, // if true, the script attachs the tooltip locally & to the body if false xOffset : 20, // x distance from mouse (no negative values) yOffset : 20, // y distance from mouse (no negative values) zIndex : 1000, // z-index of tooltip // options not supported by metadata metadata : 'class', // attribute containing the metadata, use "false" (no quotes) to disable. extradata : 'rel', // Change using the rel attribute; stores object id on the page (basic tooltip) or image URL (screenshot) activate : 'mouseenter focusin', // how tooltip is activated deactivate : 'mouseleave focusout', // how tooltip is deactivated cacheData : true, // Cache data obtained from external pages, set to false if the data is dynamic. websitePreview : 'https://api.thumbalizr.com/?width=250&url=', // use your own custom thumbnail service api string. // Callbacks initialized : null, // occurs when the tooltip is called - when hovering over an object beforeReveal : null, // occurs when the tooltip is fully formed, but still hidden revealed : null, // occurs when the tooltip is revealed hidden : null, // occurs when the tooltip is hidden (removed) // Messages loading : 'Loading...', // Message shown while content is loading notFound : 'No tooltip found', // Message shown when no tooltip content is found imagePreview : 'Image preview', // image alt message for the image shown in the preview tooltip siteScreenshot : 'URL preview: ', // image alt message for site screenshots, this message is followed by the URL // change tooltip, screenshot and preview class - note that all classes have a "." in front tooltip : '.tooltip', // tooltip class screenshot : 'a.screenshot', // screenshot class preview : 'a.preview', // preview class preloadContent : '.preload', // Add this class to preload tooltip content (not preview or screenshot). sticky : '.sticky', // Add this class to make a tooltip sticky. Only one tooltip on the screen at a time though. // events triggered on the document (NEW in v2.9) events : { init : 'jatt-initialized', b4Reveal : 'jatt-beforeReveal', reveal : 'jatt-reveal', hidden : 'jatt-hidden' }, // tooltip & preview ID (div that contains the tooltip) tooltipId : 'jatt-tooltip', // ID of actual tooltip previewId : 'jatt-preview' // ID of screenshot/preview tooltip // REMOVED // live : false // use live event support? REMOVED v2.9! }); });
Key | Value (default shown) |
Description |
---|---|---|
direction | 'n' | Choose the direction of the tooltip (in quotes; choose from n, ne, e, se, s, sw, w, nw). |
followMouse | true | When hovering over the object with a tooltip, the tooltip will follow the mouse if true. If false, it will be positioned relative to the object. |
content | 'title' | Attribute containing the tooltip content. By default it is the "title" attribute. |
speed | 300 | Time in milliseconds for the tooltip to fade in. By design the tooltip has no fade out because it is removed immediately. |
local | false | Where the tooltip is attached. By default it is false and will attach to the document body; if true, it will be attached before the object. |
xOffset | 20 | Number of pixels between the tooltip and the mouse (or object if followMouse = false) in the X direction. |
yOffset | 20 | Number of pixels between the tooltip and the mouse (or object if followMouse = false) in the Y direction. |
zIndex | 1000 | Adjust this if the tooltip is below another object. |
metadata | 'class' | Location of the tooltip metadata. By default it will look in the class attribute. If set to "false" it will disable the metadata. |
extradata | 'rel' | Change using the rel attribute; stores object id on the page (basic tooltip) or image URL (screenshot). |
activate | 'mouseenter focusin' | The event that causes the tooltip to display information. |
deactivate | 'mouseleave focusout' | The event that causes the tooltip to be removed. |
cacheData | true | Cache data obtained from external pages, set to false if the data is dynamic. |
websitePreview | 'https://api.thumbalizr.com/?width=250&url=' | use your own custom thumbnail service (api string - http://thumbalizr.com/apitools) |
initialized | null | This event/callback occurs when the tooltip is called - when hovering over an object |
beforeReveal | null | This event/callback occurs when the tooltip is fully formed, but still hidden |
revealed | null | This event/callback occurs when the tooltip is revealed |
hidden | null | This event/callback occurs when the tooltip is hidden (removed) |
loading | 'Loading...' | This message is shown while content is loading. You can also use a loading image (e.g. '<img src="images/loading.gif"/> '). It is replaced once the content has loaded. |
notFound | 'No tooltip found' | This message is shown when no tooltip content is found. |
imagePreview | 'Image preview' | This content will be added to the preview image alt attribute, so it is only seen while the image loads. |
siteScreenshot | 'URL preview: ' | This content and the site url is added to the screenshot image alt attribute, and only seen while the image loads. |
tooltip | '.tooltip' | The class used to activate the tooltip. And the ID of the actual tooltip. |
screenshot | 'a.screenshot' | The class used to activate the screenshot script which shows an image associated with the URL. And this is the ID of both the screenshot & preview tooltips. |
preview | 'a.preview' | The class used to activate the preview script which shows the an image in the tooltip from the href. |
preloadContent | 'preload' | Adding this class to the link (<a>) tells the script to preload the external content for this tooltip. This only works for regular tooltips and not preview or screenshot tooltips - they have their tooltip image automatically preloaded. |
sticky | '.sticky' | Add this class to make a tooltip sticky. Only one tooltip on the screen at a time though. |
events | See Events section below | Events that are triggered on the document when Jatt has initialized, the tooltip is about to be revealed, the tooltip has been revealed and when the tooltip is hidden. |
tooltipId | 'tooltip' | The ID of the actual tooltip. |
previewId | 'preview' | The ID of the actual preview/screenshot tooltip (the share the same one). |
Deprecated/Removed Options | ||
live | false | Removed in v2.9; Jatt now uses jQuery v1.7+ delegated binding; so it will behave as if this "live" option were always true. |
events
settings; except, the "jatt-" prefix will automatically be removed!$(function(){ $(document).on('jatt-initialized jatt-beforeReveal jatt-reveal jatt-hidden', function(event, tooltip) { var $tooltip = $(tooltip); // ignore preview & screenshot tooltips if ($tooltip.hasClass('tooltip')) { // show HTML of tooltip console.log($tooltip.html()); } }); $.jatt({ events : { init : 'jatt-initialized', b4Reveal : 'jatt-beforeReveal', reveal : 'jatt-reveal', hidden : 'jatt-hidden' }, }); });