Prototip
Prototip
Prototip allows you to easily create both simple and complex tooltips using the Prototype javascript framework.
- Style: Easy to customize.
- Position: Complete control over tooltip positions.
- Round: Configurable rounded corners, no PNG images required.
- Speech bubble effect!
- Works on all modern browsers.
View The DEMO
Installation
Upload all the files from the Prototip package to your server. The images, CSS and the Javascript. If you decide on a different folder structure you will need to set the correct paths by changing these lines in prototip.js:
images: ´../../images/prototip/´, javascript: ´´
Your document needs a doctype, I recommend using a Transitional or Strict doctype. Here´s how to setup a Transitional doctype, at the top of your document above your html tag add:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">Prototip requires Prototype 1.6.1. In the example below I´m including Prototype using the Google AJAX Libraries API. As an alternative you could download and host Prototype yourself, but by including it using Google´s AJAX Libraries API you don´t have to worry about caching and bandwidth cost.
Add Prototip below Prototype, the correct order is as in the example below.
<script type=´text/javascript´ src=´http://ajax.googleapis.com/ajax/libs/prototype/1.6.1/prototype.js´></script> <script type=´text/javascript´ src=´js/prototip/prototip.js´></script>
Add prototip.css to your header.
<link rel="stylesheet" type="text/css" href="css/prototip.css" />
tip: The Google Ajax Libraries API can be used to automatically load the latest version of Prototype. To do this you change the last part of the url to /1.6/prototype.js for the latest 1.6.* release, or /1/prototype.js for the latest 1.* release.
How to Use
Creating a tooltip is as easy as:
new Tip(element, ´content´);
To create a more advanced tooltip you can add an optional thirth parameter with options:
new Tip(element, ´content´, {
title: ´This tooltip has a title´,
style: ´protoblue´,
stem: ´topLeft´,
hook: { tip: ´topLeft´, mouse: true },
offset: { x: 14, y: 14 }
});
note: See the documentation for all the available options.
Hooking
Hooking allows you to place your tooltips anywhere in relation to your target elements. The concept is simple, you define two corners that you want to ´hook´ to eachother. One on the target element, the other one on the tooltip.
hook: { target: ´bottomRight´, tip: ´topLeft´ }
You can also hook your tooltip to the mouse pointer. Offset can be used to prevent the tooltip from appearing directly under the mouse icon.
hook: { tip: ´topLeft´, mouse: true },
offset: { x: 14, y: 14 }

note: When hooking is used on elements tooltips won´t try to stay within the viewport.
Stems
Stems are a nice way to show where the tooltip came from. After giving your tooltip a style you can set the position of the stem as shown in the example below. The image on the right shows all possible stem positions.
new Tip(element, { stem: ´topLeft´ });

note: The same positions can be used with hooking.
Ajax
Ajax tooltips allow you to pull content from an url, keeping your code clean. The content argument is left out when you use ajax. Use url to set the location for the Ajax Request. The options parameter can hold anything you would otherwise set on an Ajax.Request as options. See the Prototype API on Ajax.options and Ajax.Request for more details.
new Tip(element, {
ajax: {
url: ´/include/ajax.php´,
options: {
onComplete: function() { alert(´ajax content loaded´); }
}
}
});
Custom events
The following examples are a bit more advanced. The custom events prototip:shown and prototip:hidden allow you to call a function when tooltips open or close. You can do this by observing the element that opens the tooltip. If you have firebug installed you can run the examples below from your console, this one works on the first demonstration.
$(´demo_simple´).observe(´prototip:shown´, function() {
this.pulsate({ pulses: 1, duration: 0.3 });
});
Custom events bubble up so can monitor the document for them. This makes it possible to monitor all tooltips at once. Here´s how to call a function when every tooltip hides.
document.observe(´prototip:hidden´, function(event) {
event.element().shake(); // our target element, we shake it with Scriptaculous
});
note: Scriptaculous is used to create the effects in the custom event examples.
Automatically add tooltips
To make it a bit easier to manage tooltips you can create them automatically based on a CSS condition. Here´s how to do this for every link in the page using rel attibutes, after the page has finished loading. Since $$ accepts a CSS selector it could also be used to target different groups of elements.
document.observe(´dom:loaded´, function() {
$$(´a[rel]´).each(function(element) {
new Tip(element, element.rel);
});
});
tip: The above example shows just a fraction of what´s possible with Prototype. I recommend reading up on Prototype as much as you can, it´s a beautiful framework that will make your coding experience a lot more enjoyable.
Style
A new style can be created with a few lines of code. When opening styles.js you will see Prototip.Styles, an object containing a few predefined styles. These can be used as an example.
After you have given your style a name you will need to create a folder with the same name inside the ´images/prototip/styles/´ folder. There you can place PNG images to style the closebutton and stems. Here´s how the default tooltip is created.
´default´: {
border: 6,
borderColor: ´#c7c7c7´,
className: ´default´,
closeButton: false,
hideAfter: false,
hideOn: ´mouseleave´,
hook: false,
radius: 6,
showOn: ´mousemove´,
stem: { height: 12, width: 15 }
},
The className points to a class in prototip.css, this class is used to finetine the styling. After you´ve completed setting up your style, you can use it with the style option on a tooltip.
/* the default style */
.prototip .default { color: #808080; }
.prototip .default .toolbar {
background: #f1f1f1;
font-weight: bold;
}
.prototip .default .title { padding: 5px; }
.prototip .default .content {
padding: 5px;
background: #fff;
}

note: Prototip.Styles contains more than just styling, styles will make your Tip calls smaller.
Documentation
Tip
new Tip(element, content[, options]);
-
element
An id or an element.
new Tip(´myId´, ´text´); // id new Tip($(´myId´).down(´span.myclass´), ´text´); // element
-
content
A string or an element.
new Tip(´myId´, ´text to go into the tooltip´); // id new Tip(´myId´, new Element(´div´).update(´my text´)); // element
-
options
Optional object with options, see the documentation on Tip.options
Tip Options
The following options can be used to customize a tooltip.
-
ajax
Pull content from an url using an Ajax.Request. An object containing url and optional options. Where options are the options can would normally set on an Ajax request using Ajax.options.
new Tip(´myId´, { ajax: { url: ´page.php´, options: { method: ´get´, onComplete: function() { alert(´loaded ajax content´); } } } });note: The content argument is left out, since Ajax will get this for you.
-
border
The size of the border in pixels. If the radius is bigger than the border you have currently set the border will become bigger.
border: 6
-
borderColor
A CSS color string.
borderColor: ´#cccccc´
-
closeButton
true or false. Show or hide the closebutton.
-
delay
Delay when showing the tooltip in seconds. Default 0.14, so you can safely hover you page.
-
fixed
Set this to true if you don´t want the tooltip to follow the mouse.
-
hideAfter
Hide the tooltip after a time of inactivity in seconds. This means your tooltip will hide after the element or the tooltip is not hovered for this duration.
-
hideOn
A string with the event to use, or an object allowing more control, or false.
hideOn: ´mouseout´ hideOn: { element: ´target´, event: ´mouseout´ } hideOn: { element: ´tip´, event: ´mousemove´ } hideOn: { element: ´closeButton´, event: ´click´ } // inserts closebutton hideOn: { element: ´.close´, event: ´click´ } // ´close´ becomes closebutton hideOn: false // useful in combination with hideAfter -
hideOthers
When true, will hide all other tooltips before opening.
-
hook
An object hooking two elements together. See hooking for more details and demonstrations.
hook: { target: ´topRight´, tip: ´bottomLeft´ } hook: { target: ´rightMiddle´, tip: ´leftMiddle´ } hook: { tip: ´bottomRight´, mouse: true } -
images
This allows you to set a different image directory for the tooltip, or for a style when used in Prototip.Styles.
images: ´styles/custom/´ images: ´../../someDirectory/styles/custom/´ images: ´http://www.yoururl.com/prototip/styles/custom/´
-
offset
An object containing the x and y offset you want to give to the tooltip.
offset: { x: 16, y: 44 } -
radius
The corner radius of the border in pixels. If the radius is bigger than the border you have currently set the border will become bigger.
radius: 6
-
showOn
The event that shows the tooltip. Default: ´mousemove´.
showOn: ´click´
-
stem
A string with the stem position, an object giving more control, or false. See stems for more details on stem positions.
stem: ´topLeft´ stem: ´leftMiddle´ stem: { position: ´bottomRight´, width: 14, height: 16 } -
style
The style to use for the tooltip, defined in Prototip.Styles. Default: ´default´.
-
target
An id or an element that will function as the target for your tooltip. Default: the element in the Tip call.
target: ´myId´ target: $(´myId´).up(´li.row´)
-
title
A string with the title or the tooltip, this will insert the toolbar containing the title.
-
viewport
Keep the tooltip within the viewport. true or false.
note: Tooltips that hook to elements will not stay within the viewport.
-
width
An integer to set the width of the tooltip in pixels, a css string like ´auto´, or false. Default: false, sets the width defined in the CSS.
width: 200 width: ´auto´
Tips
Hide all visible tooltips on the page.
Remove the tooltip from an element.
Tips.remove(´myId´); // id Tips.remove($(´myId´).down(´a[rel]´)); // element
note: Calling new Tip again on an element automatically uses Tips.remove on that element.
Tips Options
These options can be configured in prototip.js.
-
images
The path to the prototip image directory, can be relative to this file or an absolute url. An absolute url is often required when url rewriting is used.
images: ´../images/prototip/´, // relative images: ´http://www.site.com/images/prototip/´, // absolute
-
zIndex
The default zIndex of the tooltips. When you are hoving tooltips zIndex will automatically increase so tooltips will always be on top. The value used here will be the starting zIndex.
Element prototip
All elements you create a tooltip for are extended with a prototip object containing a few useful functions.
-
prototip.show()
Shows the tooltip set on the element.
$(´myId´).prototip.show();
-
prototip.hide()
Hides the tooltip set on the element.
$(´myId´).prototip.hide();
-
prototip.remove()
Removes the tooltip from the element, this also removes .prototip.
$(´myId´).prototip.remove();
-
Troubleshooting
Tooltips are not showing up.
Give your page a doctype, I recommend using a Transitional doctype. Also make sure prototip.css is included.
My tooltips look different from those on the Prototip website.
This could be because prototip.css is not included or images are not uploaded. Make sure you image directory is set correctly in prototip.js. This also happens when your own css is conflicting with prototip.css. Remember not to set things globally in your own css files, rules like: li { display: inline; } are bad practice. Target your elements better, this will prevent conflicts. When your css is properly coded you should have no problem implementing Prototip.
It´s still not working.
Make sure your page validates using validator.w3.org before posting for support on the Prototip Forum. I also recommend getting Firefox with the Firebug addon, many problems posted on the forum are easily solved with the debugging it provides.
I don´t like the filesize.
If gzipping is not an option for you, have a look at Protopacked. It contains compressed versions of Prototype starting at 21kb.

25 January 2010 Monday





Comments
dubykmajor dubykmajor
2012-05-16 02:10:36In way back when decade countless online large businesses choose to go broke.Together with today wad of cash 500 providers as traditional competition and direct challenges, there is normally low chance that your new dad and mom business may well open your wholesale organization around these kinds of giants.It'll be difficult so that you can profit along with such high capital vendors budget plus weekly offers for the daily buyers.It is my estimation and conclusion of the fact that most rewarding and sound chance of making an important profit or simply a living from a discount store as well as a wholesale home business is through search engine marketing.There really are numerous factor of why I am able to support these conclusion:
Owning a wholesale business on the net takes not as much as 90 secs if you now know how to research online.While starting a small business offline calls for months and often years dependant upon state legislation, permissions and also licenses intended for opening surgical treatments.I mean contemplate it, what is usually better compared with sitting at home, having a booming wholesale business without leaving your own home while continue to enjoying your energy with your own love versions? In my opinion, there isn't a better way or option the fact that poor training and midst class can try a healthy, simple in addition to financial liberation life then an internet business.There are a number of them generating an income by selling wholesale via the internet.Take the net marketing gigantic example, craigs list.The public auction giant has 1000s of successful sellers selling right from condoms so that you can houses on a daily basis.
Developing a prospering wholesale business from the beginning can start out in well under one 100 dollars.It is possible to outsource a web development company for constructing your blog in places like China, Pakistan and various 3rd community countries at under a low to medium large nachos, while continue to having capital for advertising promotions.With a powerful offline business you would like hundreds and thousands to obtain successful brings and buyers for the shop based on your online business.So so what can be as good as an internet business for receiving passive source of income that one time successful, keeps coming and arriving for your money non-stop? In the 2006-year real truth, there will be nothing which comes additional simpler then web marketing income.You rouse in the am, check ones own email, get excited just like you see all the "Notification Associated with Payment Received", send patron order information with your secret decline ship suppliers so you count your net income for all of those other day.That of course after getting your home business with steady free normal traffic from bing in which in turn takes afternoon or months based on how light hat or simply black hat suddenly you become in the search engine optimisation world.
In the end:I advise you start your business, get a lot of experience by selling material either about eBay or for your own websites and in the long-term view start to see the rewards which might come to your selected the correct niche goods and services to provide you with online consumers.
chenostev chenostev
2012-05-16 01:16:41north face
the north facenorthface
north face jacketsnorth face outletNorth Face Shoes Men
Northface RealizationNorth Face Mens Denali JacketsNorth Face RealizationThe North Face Womens
chenostev chenostev
2012-05-16 00:40:31Wedding Dresses
Designer Bridal Gowns
Custom Wedding Dresses
Designer Prom Dresses
Prom Dress Designers
beach wedding dress
night party dress
cheap evening dresses
White Evening Dress
prom dresses
chenostev chenostev
2012-04-27 23:19:50tiffanytiffany jewelrycheap tiffany jewelry
tiffany jewelry outlettiffany jewelry replicacheap tiffany braceletswholesale tiffany earrings
tiffany ringstiffany rings cheaptiffany gold bangles
dubykmajor dubykmajor
2012-04-26 06:09:032011 New Dr Dre Studio For Christmas Gifts
Cheap Dr Dre Studio
Monster Studio Diamond Beats
Dr Dre Diamond Sale
Dr Dre Studio For Christmas
wholesale Beats Studio Kobe Bryant
Cheap Teams Logo Beats
Monster Beats Studio Wholesale
Dr Dre Beats Outlet
Monster Beats Studio Lamborghini
chenostev chenostev
2012-04-24 00:05:31Cocktail Dresses
Evening Dresses
wedding dresses
bridal gowns
bridal dresses
Mermaid Wedding Dresses sale
Wedding Dresses
Sweetheart Wedding Dresses outlet
Sweetheart Wedding Dresses outlet
buy Mother Of The Bride Dresses
dubykmajor dubykmajor
2012-04-20 21:52:26tiffany jewelry
buy tiffanytiffany outlet
tiffany onlinecheap tiffanyTiffany Bracelets sale
Tiffany Necklaces outlet
Tiffany Bracelets online
Tiffany Bracelets onlinediscount Tiffany Key Rings
dubykmajor dubykmajor
2012-04-17 12:53:46ugg australiaugg boots saleugg boots clearance
ugg boots on saleugg storeUGG AUSTRALIAugg roxy boots outletUGG BOOTS OUTLEugg boots on saleBailey Button UGG
chenostev chenostev
2012-04-01 07:24:03pandora on sale
cheap pandora
buy pandora
discount pandora
pandora
Cheap Pandora Sets
Pandora Sets Sale
Pandora Bracelets Online
Pandora Bangles online
cheap Pandora Bangles