Sha256: 45220e30ba74ad7e54ae74b7da51a8a77f270e1d7aa2bd901d4d74d3a0d5dba0

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

Trestle.ready(function() {
  var sidebar = $('.app-sidebar');

  // Toggle mobile navigation using menu button

  sidebar.find('.navbar-toggle').on('click', function(e) {
    e.preventDefault();

    $('.app-wrapper').addClass('animate');
    $('body').toggleClass('mobile-nav-expanded');
  });

  $('.app-wrapper').on('transitionend webkitTransitionEnd', function() {
    $(this).removeClass('animate');
  });


  // Interacting outside of the sidebar closes the navigation

  $('.app-wrapper').on('click touchstart', function(e) {
    var navExpanded = $('body').hasClass('mobile-nav-expanded');

    var clickInHeader = $(e.target).closest('.app-header').length;
    var clickInSidebar = $(e.target).closest('.app-sidebar').length;

    if (navExpanded && !clickInHeader && !clickInSidebar) {
      e.stopPropagation();
      e.preventDefault();

      $('.app-wrapper').addClass('animate');
      $('body').removeClass('mobile-nav-expanded');
    }
  });


  // Toggle sidebar expand/collapse

  sidebar.find('.toggle-sidebar').on('click', function(e) {
    e.preventDefault();

    if (sidebar.hasClass('expanded') || sidebar.hasClass('collapsed')) {
      sidebar.removeClass('expanded').removeClass('collapsed');
      document.cookie = "trestle:sidebar=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
    } else if ($(document).width() >= 1200) {
      sidebar.addClass('collapsed');
      document.cookie = "trestle:sidebar=collapsed; path=/";
    } else if ($(document).width() >= 768) {
      sidebar.addClass('expanded');
      document.cookie = "trestle:sidebar=expanded; path=/";
    }
  });
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trestle-0.8.4 app/assets/javascripts/trestle/_sidebar.js