Test Failed
Push — master ( 1f7378...9083a9 )
by Sebastian
04:47
created

build/coverage/.js/file.js   A

Complexity

Total Complexity 12
Complexity/F 1.33

Size

Lines of Code 61
Function Count 9

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 38
nc 1
dl 0
loc 61
c 1
b 0
f 0
cc 0
rs 10
wmc 12
mnd 1
bc 13
fnc 9
bpm 1.4443
cpm 1.3333
noi 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