Basics
Shorthand options
Several of the main options have shorthand notation for declaring their values. Most notable of these are the main option objects. If any of the main options e.g. show, position, are declared as non-objects, they map to a specific sub-option within it when parsed. An example:
$('.selector').qtip({ content: 'Short hand notation' }); $('.selector').qtip({ content: { text: 'Long hand notation' // Notice that content.text is long-hand for simply declaring content as a string } });
Here's a list of all available short hands:
metadata: 'string' -> metadata: { type: 'string' } content: 'string' -> content: { text: 'string' } position: 'string' -> position: { my: 'string', at: 'string' } // This one is special - it maps to two options (my & at) show: 'string' -> show: { event: 'string' } show: $('.selector') -> show: { target: $('.selector') } hide: 'string' -> hide: { event: 'string' } hide: $('.selector') -> hide: { target: $('.selector') } style: 'string' -> style: { classes: 'string' } /* Plugin-specific */ style: { tip: 'string or boolean' } -> style: { tip: { corner: 'string or boolean' } } show: { modal: boolean } -> show: { modal: { on: boolean } }
NB Shorthand notation is only of help when you don't need to specify any other options for the object except for the sub-option(s) it maps to!
Custom effects
qTip used to come packed with 3 default effects: fade, slide and grow. Slide and grow have been removed in 2.x in favour of user-defined effects. Let's take a look at their equivalents using custom effect callbacks:
// Slide up/down effects effect: function() { $(this).slideDown(100); } // Show effect: function() { $(this).slideUp(100); } // Hide // Grow effects effect: function() { $(this).show(100); } // Show effect: function() { $(this).hide(100); } // Hide
As you might guess, you're not limited to just the usual hide/show methods either. You can utilise the .animate method to create some pretty groovy effects:
// Shrink to the left and fade out effect: function() { $(this).animate({ width: 0, opacity: 0 }, { duration: 100 }); } // Can even use jQuery UI's custom effects effect: function() { $(this).show('slide', null, 100); } effect: function() { $(this).hide('bounce', null, 100); }
The possibilities are pretty much endless, so go forth young padawan!
