Table of contents

smallipop logo
smallipop

Created by Sebastian Helzle

This is a jQuery plugin for displaying tooltips.
There are a lot of other plugins for this task, but they didn't meet our
various requirements at Small Improvements.

So finally we decided to create our own plugin and wanted to share it with you!


Download smallipop now   Visit smallipop at github


Licensed under the MIT license.


Features


We are using this plugin for a lot of things, so watch for new releases at github.

New and improved in this version

+ Click here to see changes in the last versions


Dependencies





Image with absolute positioned hints:

Hints can be positioned anywhere, even on absolute positioned or floating elements.


Bird in china
+
 
Black hole sun
+
 
The bird is the word

This bubble has a white theme extended by another sub theme 'transparent'.

Also the trigger is made out of pure css.
arrow
It's a house!

It has an image as trigger.
We have provided some you can use in the images folder.

+ Click here to see how it's done

$('.myElement').smallipop({
    hideTrigger: true, // Trigger is hidden when the bubble is shown
    theme: 'white whiteTransparent', // White theme is used with it's transparent extension
    popupYOffset: 20, // Bubble has a 20px vertical offset
    popupDistance: 30, // Bubble travels vertically by 30px when fading in
    popupOffset: 0, // No horizontal offset
});


Text with inline hints:


Something completely different

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt Some info about invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam

accusam

Bird in china

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.

Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?

et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Create a smallipop

Here is the easiest way to create a smallipop:

<a class="myElement" href="#" title="That was easy!">And now hover me!</a>

Then add some javascript:

<script type="text/javascript">
    $(function() {
        $('.myElement').smallipop();
    });
</script>

And now hover me!



If you like some markup as tooltip, you can do that as well
<span class="smallipop">
    Hover me!
    <div class="smallipopHint">
        <b>Give me some markup!</b>
    </div>
</span>

Hover me!
Give me some markup



You can provide the content for the bubble via javascript too
<a href="#" id="tipcustomhint" title="I'm the old title">
    Hover me!
</a>

Add some javascript to the mix:

$('#tipcustomhint').smallipop({}, "I'm the real hint!");

Hover me!


There are cases when the trigger is replaced or changed when clicked and the tooltip needs to be hidden
<div id="sampleContainer">
    <a href="#" id="tipkiller" class="smallipop" title="Click the link and I will be gone">
        Hover me!
    </a>
</div>
                

With this javascript:

$('#tipkiller').click(function(e) {
    e.preventDefault();
    $('#sampleContainer').html('<div>Some new content</div>');
});




Elements can be positioned everywhere, smallipop will be at the right position
<div class="smallipop" style="float:right;">
    Hover me! 
    <span class="smallipopHint">
        <b>Markuptip with very long text</b><br/>
        ...
    </span>
</div>

Look to the right!

Hover me! Markuptip with very long text
and a link with some javascript which replaces the trigger



How about showing the bubble on the left or right of an element?
<span class="smallipopHorizontal">
    Hover me!
    <span class="smallipopHint">
        Good for dropdowns!
    </span>
</span>

With this javascript:

$('.smallipopHorizontal').smallipop({
    horizontal: true,
    theme: 'black',
    popupOffset: 10,
    invertAnimation: true
});

Hover me! Good for dropdowns! Or me! Auto align when there's no room on the right.

Don't like animations? No Problem
<a class="smallipopStatic" title="Doesn't move an inch">
    Hover me!
</a>

With this javascript:

$('.smallipopStatic').smallipop({
    theme: 'black',
    popupDistance: 0,
    popupYOffset: -14,
    popupAnimationSpeed: 100
});

Hover me!

Change default positioning
<a class="smallipopStatic" title="Below when possible">
    Hover me!
</a>

With this javascript:

$('.smallipopBottom').smallipop({
    theme: 'black',
    preferredPosition: 'bottom'
});

Hover me!

Themes:

Hover the links to see the different themes


Default theme  -  Blue theme  -  Black theme  -  White theme  -  Orange theme

You can extend a theme with an extension theme:


$('.myElement').smallipop({ theme: 'blue fatShadow' });

Hover me! Look at this fat shadow!


The css for the extension theme looks like this:

#smallipop.fatShadow {
  -webkit-box-shadow: 0 2px 20px rgba(0, 0, 0, 0.8);
     -moz-box-shadow: 0 2px 20px rgba(0, 0, 0, 0.8);
          box-shadow: 0 2px 20px rgba(0, 0, 0, 0.8);
}

This allows you to have one basic theme and several subthemes with different border styles or colors for example.


Options

Key Default value Description
popupOffset 31 Horizontal offset for the popup from the center of the trigger when the popup is aligned left or right.
popupYOffset 0 Vertical offset for the popup.
popupDistance 20 Vertical distance when the popup appears and disappears.
hideTrigger false Hide the trigger when the popup is shown.
Theme default black, blue, white and a default theme are included in the css file.
infoClass smallipopHint Class in an element which contains markup content for the popup.
popupDelay 100 How much time in milliseconds you have to hover on an element before the popups shows up.
triggerAnimationSpeed 150 How fast the trigger fades in and out when hideTrigger is set.
popupAnimationSpeed 200 How much time the popup needs to reach it's final animation position and opacity in milliseconds.
windowPadding 30 Distance to the window borders the smallipop should keep when computing it's orientation.
invertAnimation false The popup will move up when an element is hovered and further up when fading out. If you set this to true, the popup will move down when fading out.
horizontal false The popup will be positioned left or right of the trigger.
preferredPosition top Use "top" or "bottom" for the default layout and "left" or "right" when horizontal mode is active.
windowPadding 30 Minimal distance smallipop should keep try to keep to the window borders.
triggerOnClick false Disables the hover event for triggers and smallipop will be activated by clicking the trigger.
A second click will trigger the default action on the trigger. I.e. open a link.
touchSupport true When touch events are supported hover events are disabled and smallipop will activated by touching a trigger.
A second touch will trigger the default action on the trigger. I.e. open a link. The touch feature detection currently requires the modernizr library.
funcEase easeInOutQuad Easing function for the animations.

Installation

Prequisites

Both are also provided in the lib folder. If you don't want to use the Modernizr library you should remove the
.cssgradients, .borderradius, .rgba and .boxshadow classes in css/jquery-smallipop.css.


Required files

1. Copy lib/jquery-smallipop.js to your javascript folder.

2. Copy lib/jquery-x.x.x.min.js to your javascript folder if you don't use jQuery already.

3. Copy lib/modernizr-x.x.x.js to your javascript folder if you don't use modernizr already.

4. Copy css/jquery-smallipop.css to your css folder.

There is a minified version of the smallipop javascript for production in the lib folder too.


Modify your html header

Add these lines to the header of your html file and replace x.x.x with the correct versions

<link rel="stylesheet" href="css/jquery-smallipop.css" type="text/css" media="all" title="Screen"/>   
<script type="text/javascript" src="lib/jquery-x.x.x.min.js"></script>   
<script type="text/javascript" src="lib/modernizr-x.x.x.min.js"></script>   
<script type="text/javascript" src="lib/jquery-smallipop.js"></script>

Coming up


Have fun and check out my other plugins


jQuery Rondell


Feedback is welcome!

Please send me suggestions, ideas for improvement or anything else to sebastian@small-improvements.com or @sebobo


© 2012 by Small Improvements


Smallipop is powered by coffeescript and sass.