Sha256: 460e7643c70b4bdccb2c2a4d39b831b19350a8884d4c1bac58e0a0994a22c353

Contents?: true

Size: 1.91 KB

Versions: 2

Compression:

Stored size: 1.91 KB

Contents

(function (){

  function getSideNavHeight() {
    var hasSideNavHeader = $('.navbar-header').length > 0
    return hasSideNavHeader ? $('.nav-side-menu').outerHeight() - $('.navbar-header').outerHeight() : $('.nav-side-menu').outerHeight()
  }

  function initSidenav() {
    var width = document.body.clientWidth;
    var sideNavTrackColor = KisoThemes.getRootCssVariable('--sidenav-track-color');

    var sideNavContainer = $('.nav-side-container')

    if(!sideNavContainer.length) {
      return
    }

    sideNavContainer = $(sideNavContainer[0]);

    $('.SideNavToggle').on('click', function() {
      $('body').toggleClass(
        'show-sidebar'
      )
    })

    if (!Modernizr.touch && width > 992) {
      sideNavContainer.slimScroll({
        height: getSideNavHeight(),
        color: sideNavTrackColor,
        size: '4px',
        opacity: 0.9,
        wheelStep: 15,
        distance: '0',
        railVisible: false,
        railOpacity: 1
      });

      sideNavContainer.mouseover();
    } else {
      sideNavContainer.slimScroll({ destroy: 'true' });

      sideNavContainer.mouseover();
    }

    $(window).on('resize', KisoThemes.debounce(function() {
      if (Modernizr.touch) return;

      width = document.body.clientWidth;

      if (width < 992) {
        sideNavContainer.slimScroll({ destroy: 'true' });
        sideNavContainer.height('auto')

        sideNavContainer.mouseover();
      } else {
        sideNavContainer.slimScroll({ destroy: 'true' });
        sideNavContainer.slimScroll({
          height: getSideNavHeight(),
          color: sideNavTrackColor,
          size: '4px',
          opacity: 0.9,
          wheelStep: 15,
          distance: '0',
          railVisible: false,
          railOpacity: 1
        });

        sideNavContainer.mouseover();
      }
    }, 250));
  }

  KisoThemes.hookOnPageLoad( function() {
    KisoThemes.jsLibIsActive('sidenav') && initSidenav.call(this)
  })
})()

Version data entries

2 entries across 1 versions & 1 rubygems

Version Path
kiso_themes-1.0.2 app/assets/javascripts/kiso_themes/sidenav.js
kiso_themes-1.0.2 lib/generators/kiso_themes/templates/rails6/kiso_themes/sidenav.js