Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ To use css3 animation effects please include [Animate.css](http://daneden.github
| onBeforeShow | function(){} | Function to be executed before tipso is shown |
| onShow | function(){} | Function to be executed after tipso is shown |
| onHide | function(){} | Function to be executed after tipso is hidden |
| showEvents | 'mouseover' | Array or space separated list of events that should trigger the tooltip to show |
| hideEvents | 'mouseout' | Array or space separated list of events that should trigger the tooltip to hide |

> Additionaly you can use `data-tipso` instead of the title attribute for the tooltip content ( set `useTitle: false` )

Expand Down
24 changes: 19 additions & 5 deletions src/tipso.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
templateEngineFunc: null, //A function that compiles and renders the content
onBeforeShow : null,
onShow : null,
onHide : null
onHide : null,
showEvents : 'mouseover', //The events that trigger the tooltip to be shown
hideEvents : 'mouseout' //The events that trigger the tooltip to be hidden
};

function Plugin(element, options) {
Expand Down Expand Up @@ -112,17 +114,29 @@
$doc = this.doc;
$e.addClass('tipso_style').removeAttr('title');

var showEvents = (typeof obj.settings.showEvents == 'object') ? obj.settings.showEvents : obj.settings.showEvents.split(' ');
for (var i in showEvents) {
showEvents[i] = String(showEvents[ i ] + '.' + pluginName).trim();
}
showEvents = showEvents.join( ' ' );

var hideEvents = (typeof obj.settings.hideEvents == 'object') ? obj.settings.hideEvents : obj.settings.hideEvents.split(' ');
for (var i in hideEvents) {
hideEvents[i] = String(hideEvents[ i ] + '.' + pluginName).trim();
}
hideEvents = hideEvents.join( ' ' );

if (obj.settings.tooltipHover) {
var waitForHover = null,
hoverHelper = null;
$e.on('mouseover' + '.' + pluginName, function() {
$e.on(showEvents, function() {
clearTimeout(waitForHover);
clearTimeout(hoverHelper);
hoverHelper = setTimeout(function(){
obj.show();
}, 150);
});
$e.on('mouseout' + '.' + pluginName, function() {
$e.on(hideEvents, function() {
clearTimeout(waitForHover);
clearTimeout(hoverHelper);
waitForHover = setTimeout(function(){
Expand All @@ -143,10 +157,10 @@
;
});
} else {
$e.on('mouseover' + '.' + pluginName, function() {
$e.on(showEvents, function() {
obj.show();
});
$e.on('mouseout' + '.' + pluginName, function() {
$e.on(hideEvents, function() {
obj.hide();
});
}
Expand Down