Skip to content

Instantly share code, notes, and snippets.

@dtomasi
Created December 27, 2013 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtomasi/d0b742bf22efdec670e6 to your computer and use it in GitHub Desktop.
Save dtomasi/d0b742bf22efdec670e6 to your computer and use it in GitHub Desktop.
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