Last active
June 8, 2016 07:59
-
-
Save zukilover/4ba0542ef71a4a4b4a2227a7689e1fed to your computer and use it in GitHub Desktop.
Initiate custom popover
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
$(s.customPopover).each(function () { | |
if (!$().popover) return; | |
var popover = $(this), | |
backdrop = popover.data('backdrop'), | |
content = popover.attr('href') || popover.data('popover-content'), | |
getHtml; | |
$(content).hide(); | |
getHtml = function(){ | |
return $(content).html(); | |
} | |
popover.popover({ | |
html : true, | |
content : getHtml, | |
trigger : 'manual' | |
}) | |
.on('shown.bs.popover', function () { | |
$(document).on('click', '[data-dismiss=popover]', function(){ | |
popover.popover('hide'); | |
}); | |
}) | |
.on('show.bs.popover', function () { | |
if( backdrop ){ | |
$('<div/>').addClass('modal-backdrop fade in').appendTo('body'); | |
$('body').addClass('ovh'); | |
} | |
}) | |
.on('hidden.bs.popover', function () { | |
if( backdrop ){ | |
$('.modal-backdrop').remove(); | |
$('body').removeClass('ovh'); | |
} | |
}); | |
popover.on('click', function(e){ | |
e.preventDefault(); | |
popover.popover('show'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment