| Total Complexity | 12 |
| Complexity/F | 1.33 |
| Lines of Code | 61 |
| Function Count | 9 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | $(function() { |
||
| 2 | var $window = $(window) |
||
| 3 | , $top_link = $('#toplink') |
||
| 4 | , $body = $('body, html') |
||
| 5 | , offset = $('#code').offset().top |
||
| 6 | , hidePopover = function ($target) { |
||
| 7 | $target.data('popover-hover', false); |
||
| 8 | |||
| 9 | setTimeout(function () { |
||
| 10 | if (!$target.data('popover-hover')) { |
||
| 11 | $target.popover('hide'); |
||
| 12 | } |
||
| 13 | }, 300); |
||
| 14 | }; |
||
| 15 | |||
| 16 | $top_link.hide().click(function(event) { |
||
| 17 | event.preventDefault(); |
||
| 18 | $body.animate({scrollTop:0}, 800); |
||
| 19 | }); |
||
| 20 | |||
| 21 | $window.scroll(function() { |
||
| 22 | if($window.scrollTop() > offset) { |
||
| 23 | $top_link.fadeIn(); |
||
| 24 | } else { |
||
| 25 | $top_link.fadeOut(); |
||
| 26 | } |
||
| 27 | }).scroll(); |
||
| 28 | |||
| 29 | $('.popin') |
||
| 30 | .popover({trigger: 'manual'}) |
||
| 31 | .on({ |
||
| 32 | 'mouseenter.popover': function () { |
||
| 33 | var $target = $(this); |
||
| 34 | |||
| 35 | $target.data('popover-hover', true); |
||
| 36 | |||
| 37 | // popover already displayed |
||
| 38 | if ($target.next('.popover').length) { |
||
| 39 | return; |
||
| 40 | } |
||
| 41 | |||
| 42 | // show the popover |
||
| 43 | $target.popover('show'); |
||
| 44 | |||
| 45 | // register mouse events on the popover |
||
| 46 | $target.next('.popover:not(.popover-initialized)') |
||
| 47 | .on({ |
||
| 48 | 'mouseenter': function () { |
||
| 49 | $target.data('popover-hover', true); |
||
| 50 | }, |
||
| 51 | 'mouseleave': function () { |
||
| 52 | hidePopover($target); |
||
| 53 | } |
||
| 54 | }) |
||
| 55 | .addClass('popover-initialized'); |
||
| 56 | }, |
||
| 57 | 'mouseleave.popover': function () { |
||
| 58 | hidePopover($(this)); |
||
| 59 | } |
||
| 60 | }); |
||
| 61 | }); |
||
| 62 |