/* @name BeautyTips * @desc a tooltips/baloon-help plugin for jQuery * @author Jeff Robbins - Lullabot - http://www.lullabot.com * @version 0.9.5 release candidate 1 (5/20/2009) */ jQuery.bt = {version: '0.9.5-rc1'}; /* @type jQuery * @cat Plugins/bt * @requires jQuery v1.2+ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * Encourage development. If you use BeautyTips for anything cool * or on a site that people have heard of, please drop me a note. * - jeff ^at lullabot > com * No guarantees, warranties, or promises of any kind */ ;(function($) { /* @credit Inspired by Karl Swedberg's ClueTip * (http://plugins.learningjquery.com/cluetip/), which in turn was inspired * by Cody Lindley's jTip (http://www.codylindley.com) * Usage: * The function can be called in a number of ways. * $(selector).bt(); * $(selector).bt('Content text'); * $(selector).bt('Content text', {option1: value, option2: value}); * $(selector).bt({option1: value, option2: value}); * For more/better documentation and lots of examples, visit the demo page included with the distribution */ jQuery.fn.bt = function(content, options) { if (typeof content != 'string') { var contentSelect = true; options = content; content = false; } else { var contentSelect = false; } if (jQuery.fn.hoverIntent && jQuery.bt.defaults.trigger == 'hover') { jQuery.bt.defaults.trigger = 'hoverIntent'; } return this.each(function(index) { var opts = jQuery.extend(false, jQuery.bt.defaults, jQuery.bt.options, options); opts.overlap = -10; var ajaxTimeout = false; if (opts.killTitle) { $(this).find('[title]').andSelf().each(function() { if (!$(this).attr('bt-xTitle')) { $(this).attr('bt-xTitle', $(this).attr('title')).attr('title', ''); } }); } if (typeof opts.trigger == 'string') { opts.trigger = [opts.trigger]; } if (opts.trigger[0] == 'hoverIntent') { var hoverOpts = jQuery.extend(opts.hoverIntentOpts, { over: function() { this.btOn(); }, out: function() { this.btOff(); }}); $(this).hoverIntent(hoverOpts); } else if (opts.trigger[0] == 'hover') { $(this).hover( function() { this.btOn(); }, function() { this.btOff(); } ); } else if (opts.trigger[0] == 'now') { if ($(this).hasClass('bt-active')) { this.btOff(); } else { this.btOn(); } } else if (opts.trigger[0] == 'none') { } else if (opts.trigger.length > 1 && opts.trigger[0] != opts.trigger[1]) { $(this) .bind(opts.trigger[0], function() { this.btOn(); }) .bind(opts.trigger[1], function() { this.btOff(); }); } else { $(this).bind(opts.trigger[0], function() { if ($(this).hasClass('bt-active')) { this.btOff(); } else { this.btOn(); } }); } this.btOn = function () { if (typeof $(this).data('bt-box') == 'object') { this.btOff(); } opts.preBuild.apply(this); $(jQuery.bt.vars.closeWhenOpenStack).btOff(); $(this).addClass('bt-active ' + opts.activeClass); if (contentSelect && opts.ajaxPath == null) { if (opts.killTitle) { $(this).attr('title', $(this).attr('bt-xTitle')); } content = $.isFunction(opts.contentSelector) ? opts.contentSelector.apply(this) : eval(opts.contentSelector); if (opts.killTitle) { $(this).attr('title', ''); } } if (opts.ajaxPath != null && content == false) { if (typeof opts.ajaxPath == 'object') { var url = eval(opts.ajaxPath[0]); url += opts.ajaxPath[1] ? ' ' + opts.ajaxPath[1] : ''; } else { var url = opts.ajaxPath; } var off = url.indexOf(" "); if ( off >= 0 ) { var selector = url.slice(off, url.length); url = url.slice(0, off); } var cacheData = opts.ajaxCache ? $(document.body).data('btCache-' + url.replace(/\./g, '')) : null; if (typeof cacheData == 'string') { content = selector ? $("
").append(cacheData.replace(/