You are on page 1of 2

(function($) { var defaults = { className: 'tb_tooltip', maxWidth: 300, speed: 10, fadeSpeed: 400, xOffset: 30, yOffset: -30

}; var tbtool = function (el, msg, options ) { this.settings = $.extend( {}, defaults, options ); this.$el = $(el); this.tbtoolMain = $( '<div></div>' ).addClass( this.settings.className ) .css({ 'position': 'absolute', 'top' : 0 + this.settings.yOffset + 'px', 'left' : 0 + this.settings.xOffset + 'px' }); this.tbtoolTop = $( '<div></div>' ).addClass( this.settings.className + '_top' ); this.tbtoolContent = $( '<div></div>' ).addClass( this.settings.className + '_content' ).html(msg); this.tbtoolBottom = $( '<div></div>' ).addClass( this.settings.className + '_bottom' ); this.tbtoolMain.append( this.tbtoolTop, this.tbtoolContent, this.tbtoolBottom ).hide(); $( 'body' ).append( this.tbtoolMain ); //turn on event listeners this.turnOn(); }; tbtool.prototype = { tbshow: function( e ) { var root = this; this.tbtoolMain.fadeIn( root.settings.fadeSpeed ); this.$el.on( 'mousemove', $.proxy(this.onMouseMove, this )); }, tbhide: function( e ) { var root = this; this.tbtoolMain.fadeOut( root.settings.fadeSpeed ); this.$el.off( 'mousemove' ); }, onMouseMove: function( e ) { this.tbtoolMain.css({ 'top': e.pageY + this.settings.yOffset + 'px', 'left': e.pageX + this.settings.xOffset + 'px' }); },

turnOff: function () { this.$el.off( 'mouseover' ); this.$el.off( 'mouseout' ); }, turnOn: function() { this.$el.on( 'mouseover', $.proxy( this.tbshow, this )); this.$el.on( 'mouseout', $.proxy( this.tbhide, this)); } } $.fn.tbTooltip = function(msg, options) { return new tbtool(this, msg, options); } })(jQuery); (function( $ ) { $.fn.preventMultipleClicks = function() { var isPrevClicked = this.data( 'submit' ), self = this; this.click = function( e ) { if ( isPrevClicked ) { e.preventDefault(); } else { self.data( 'submit', 'true' ); } } } })(jQuery);

You might also like