Skip to content

Instantly share code, notes, and snippets.

@lukmdo
Created August 7, 2012 17:14
Show Gist options
  • Save lukmdo/3287421 to your computer and use it in GitHub Desktop.
Save lukmdo/3287421 to your computer and use it in GitHub Desktop.
$.fn.persistantPopover = function() {
var popoverTimeout;
function delay() {
popoverTimeout = setTimeout(function() {
$('.popover').hide();
}, 100);
}
return this.each(function() {
var $this = $( this );
$this.popover({
trigger: 'manual',
placement: 'right',
animation: false,
title: this.firstChild.textContent + '<a href="' + $this.data('source') + '">Website</a>'
});
})
.mouseenter(function() {
clearTimeout( popoverTimeout );
$('.popover').remove();
$( this ).popover('show');
})
.mouseleave(function() {
delay();
$('.popover').mouseenter(function() {
clearTimeout( popoverTimeout ) ;
}).mouseleave(function() {
delay();
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment