Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ToolTip-Plugin
/**
* jQuery Plugin ToolTip
* @copyright tomasiMEDIA 2013
* @author Dominik Tomasi
* @date 27.12.13
*/
var ToolTipPlugin = {
settings: {
mode: 'hover',
'itemSelector': '.plus',
'toolTipItemSelector': '.infoBox'
},
init: function(settings){
this.settings = $.extend(this.settings,settings);
var $this = this;
this.items = $(this.settings.itemSelector);
this.items.each(function(){
$(this).css('cursor','pointer');
switch ($this.settings.mode){
case 'click':
$(this).click(function(){
var element = $(this).find($this.settings.toolTipItemSelector);
if (element.hasClass('visible')){
element.fadeOut().removeClass('visible');
} else {
element.fadeIn().addClass('visible');
}
return false;
});
break;
default :
$(this).hover(function(){
$(this).find($this.settings.toolTipItemSelector).fadeIn();
},function(){
$(this).find($this.settings.toolTipItemSelector).fadeOut();
});
break;
}
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.