Completed
Push — dev5 ( 76b71a...013a5b )
by Ron
11:53
created

resources/js/template_files/hoverable-collapse.js   A

Complexity

Total Complexity 7
Complexity/F 3.5

Size

Lines of Code 25
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 18
mnd 5
bc 5
fnc 2
dl 0
loc 25
rs 10
bpm 2.5
cpm 3.5
noi 0
c 0
b 0
f 0
1
(function($) {
2
  'use strict';
3
  //Open submenu on hover in compact sidebar mode and horizontal menu mode
4
  $(document).on('mouseenter mouseleave', '.sidebar .nav-item', function(ev) {
5
    var body = $('body');
6
    var sidebarIconOnly = body.hasClass("sidebar-icon-only");
7
    var sidebarFixed = body.hasClass("sidebar-fixed");
8
    if (!('ontouchstart' in document.documentElement)) {
9
      if (sidebarIconOnly) {
10
        if (sidebarFixed) {
11
          if (ev.type === 'mouseenter') {
12
            body.removeClass('sidebar-icon-only');
13
          }
14
        } else {
15
          var $menuItem = $(this);
16
          if (ev.type === 'mouseenter') {
17
            $menuItem.addClass('hover-open')
18
          } else {
19
            $menuItem.removeClass('hover-open')
20
          }
21
        }
22
      }
23
    }
24
  });
25
})(jQuery);