Created
December 27, 2013 10:32
-
-
Save dtomasi/d0b742bf22efdec670e6 to your computer and use it in GitHub Desktop.
ToolTip-Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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