Skip to content

Commit

Permalink
Fix popover bug and improve it with hoverIntent
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 20, 2012
1 parent 15e2c19 commit 58f7973
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
1 change: 1 addition & 0 deletions index.html
Expand Up @@ -144,6 +144,7 @@ <h2>Getting Involved</h2>
</div>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="site/js/jquery.hoverIntent.min.js"></script>
<script src="site/js/bootstrap.min.js"></script>
<script src="site/js/main.js"></script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion labs
Submodule labs updated from 5cc7d3 to c800c4
9 changes: 9 additions & 0 deletions site/js/jquery.hoverIntent.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 16 additions & 7 deletions site/js/main.js
@@ -1,13 +1,22 @@
/*global $ */
(function() {
'use strict';

// Demos popover
$('#demos li a').popover({
delay: 200,
placement: 'in right',
title: function() {
return $( this ).text() + '<a href="' + $( this ).data('source') + '">Go to site</a>';
}
}).on('click', '.popover', function( e ) {
function hover() {
$( this ).popover('toggle');
}

$('#demos li a').each(function() {
var $this = $( this );
$this.popover({
placement: 'in right',
title: $this.text() + '<a href="' + $this.data('source') + '">Go to site</a>'
});
})
.off()
.hoverIntent( hover, hover )
.on('click', '.popover', function( e ) {
// Prevent click on the popover, but allow links inside
if ( e.target.nodeName.toLowerCase() !== 'a' ) {
e.preventDefault();
Expand Down

0 comments on commit 58f7973

Please sign in to comment.