A lightweight jQuery based balloon tip library
RaccoonTip is a small Javascript library which lets you display HTML, DOM elements or text in a balloon tip with ease. It uses jQuery (http://jquery.com) and is tested in IE6+, Firefox 3+, Safari 3+ and Chrome5+. RaccoonTip does NOT require images and is rendered with CSS3.
Just include RaccoonTip after you have included jQuery:
<script src="path/to/jquery.js" type="text/javascript"></script> <script src="path/to/raccoon_tip.js" type="text/javascript"></script>
Note: include raccoon_tip.min.js
for the minified RaccoonTip library
Make sure you put the jquery
directory in the same directory as the RaccoonTip library:
|-raccoon_tip.js |~jquery `-core.js
Just include RaccoonTip:
<script src="path/to/raccoon_tip.js" type="text/javascript"></script>
Note: include raccoon_tip.min.js
for the minified RaccoonTip library
The RaccoonTip module provides you the following three functions:
display
– Thecore
function for displaying the RaccoonTipregister
– Instruct RaccoonTip to callRaccoonTip.display
when a certain event is triggered on certain elements (at default theclick
event)close
– This function closes the RaccoonTip of course
As already mentioned, this is the core function for displaying RaccoonTip. This function accepts the following arguments:
target
– The element which RaccoonTip points tocontent
– The content which will be displayed within RaccoonTip: this can be eithernull
(for dynamic content), HTML, DOM elements or textoptions
– A simple hash which customizes RaccoonTip
duration
– default:"fast"
This influences the speed with which RaccoonTip will be displayed (see also http://api.jquery.com/show)position
– default:"bottom_right"
The default position with which RaccoonTip will attempt to display itself (it searches for an alternative when displayed outside the window viewport)beforeShow
– default:function() {}
A callback function called before showing RaccoonTip (handy for altering RaccoonTip’s content dynamically)canHide
– default:function() { return true; }
A function which will only close RaccoonTip when the function returns atrue
valueafterHide
– default:function() {}
A callback function called after hiding RaccoonTip
<script> RaccoonTip.display("#page_menu a.login", "#login_menu", {duration: "slow"}); </script>
You can use RaccoonTip.register
to instruct RaccoonTip to display itself when a certain event on certain elements are triggered. It accepts the same arguments as RaccoonTip.display
.
The options available are the options listed in Display along with:
event
– default:"click"
The event that triggers the call toRaccoonTip.display()
<script> RaccoonTip.register( "a.tip", null, { event: "hover", beforeShow: function(content, options) { $(this).html(randomText()); } } ); </script>
You can close the RaccoonTip just by clicking outside it. But you can also close it by calling the close function:
<a href="#" onclick="RaccoonTip.close(); return false">Close</a>
or
<script> RaccoonTip.close(); </script>
It’s easy as 1-2-3!
Please take a look at http://archan937.github.com/raccoon_tip for a live demo.
For support, remarks and requests please mail me at paul.engel@holder.nl.
This Javascript library depends on the jQuery library:
Copyright © 2011 Paul Engel, released under the MIT license
http://holder.nl – http://github.com/archan937 – http://codehero.es – http://gettopup.com – http://twitter.com/archan937 – paul.engel@holder.nl
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.