jLinkPreview is a plug-in for jQuery Library which simply allows you to see link's preview image before you visit them by just hovering on it. Link Preview will appear by your cursor when you hover.
Plug-in detects the <a> tags in whole page with the given specifications and enables hover Link Preview property for them. Preview images are provided by wimg.ca
JavaScript Side:
$().jLinkPreview();
HTML Side:
<a href="http://www.sarpdoruktahmaz.com">Sarpdoruk TAHMAZ</a>
If plug-in is called without any parameters, it uses default values, the exact output would be like this for the previous call of the plug-in.
.jLinkPreview
is mandatory to use, you cannot change
its name or else plug-in won't work..jLinkPreview
class.Parameters are available to use for you to customize jLinkPreview.
$().jLinkPreview({
'preload': true,
'width': 256,
'height': 192,
'fade': 300,
'background-color': '#333',
'elementsHavingId': '',
'elementsHavingClass': '',
'attribute': 'title'
});
Here are the parameters, default values, available values and descriptions:
Name | Default | Available | Description |
---|---|---|---|
preload |
true |
true false
|
true: Previews are loaded into the browsers
cache at the same time page loads. You don't wait for previews to load.
false:
Previews will be loaded when link are hovered which sometimes can consume time but this setting is
bandwidth-friendly.
|
width |
256 |
128 to |
Width of the preview. Recommended values: 128x96,
|
height |
192 |
96 to 384 |
Height of the preview. Recommended values: 128x96,
256x |
fade |
300 |
1 to X
| MilliSecond (ms) value for the preview to fade-in. |
background-color |
#333 |
#000 to #FFF |
Background color of the preview box. |
elementsHavingId |
'' |
anyId |
You can specify list of id s for plug-in to consider.
You can provide more than one id by sperating them with commas (,)
Ex. 'myId,yourId,anotherId'
Using this property will disable other previews except elements having classes provided with elementsHavingClass property.
|
elementsHavingClass |
'' |
anyClass |
You can specify list of class es for plug-in to consider.
You can provide more than one class by sperating them with commas (,)
Ex. 'myclass,yourClass,anotherClass'
Using this property will disable other previews except elements having ids provided with elementsHavingId property.
For elements having more than one class, it is enough to provide one of those classes to the plug-in. |
attribute |
title |
any <a> attr |
Attribute of the <a> element which contains the title for the preview box.
Ex. <a href='...'
title='My Title'>
Ex. <a href='...'
rel='My Title'>
Links which don't have the provided attribute won't have any title on their previews. HTML5 supports custom tags, you can use them as well. Ex. <a href='...'
customTag='My Title'>
|
Performance of the plug-in depends on the
preview image service provider.
Preview box adjusts itself automatically around the cursor, if it does not fit in browser's
window then it appears on the other side of the cursor.
Examples are based on the following settings:
$().jLinkPreview({
'preload': true,
'width': 256,
'height': 192,
'fade': 300,
'background-color': '#333',
'elementsHavingId': '',
'elementsHavingClass': '',
'attribute': 'title'
});
<a title="Google" href="google.com">Google</a> // With a title attribute.
Google.com
<a href="youtube.com">Youtube</a> // WithOUT a title attribute.
Youtube.com
<a title="Tweeet!" href="twitter.com">Twitter</a> // With a title attribute.
Twitter.com
Internet Explorer support is planned in upcoming versions.
Copyright © 2011 Sarpdoruk Tahmaz, released under GPL version 2 license.