app/assets/javascripts/trestle/components/_sidebar.js in trestle-0.8.6 vs app/assets/javascripts/trestle/components/_sidebar.js in trestle-0.8.7
- old
+ new
@@ -1,25 +1,27 @@
Trestle.ready(function() {
+ var body = $('body');
+ var wrapper = $('.app-wrapper');
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');
+ wrapper.addClass('animate');
+ body.toggleClass('mobile-nav-expanded');
});
- $('.app-wrapper').on('transitionend webkitTransitionEnd', function() {
+ wrapper.on('transitionend webkitTransitionEnd', function() {
$(this).removeClass('animate');
});
// Interacting outside of the sidebar closes the navigation
- $('.app-wrapper').on('click touchstart', function(e) {
+ 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;
@@ -36,17 +38,17 @@
// 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');
+ if (body.hasClass('sidebar-expanded') || body.hasClass('sidebar-collapsed')) {
+ body.removeClass('sidebar-expanded').removeClass('sidebar-collapsed');
Trestle.cookie.delete("trestle:sidebar");
} else if ($(document).width() >= 1200) {
- sidebar.addClass('collapsed');
+ body.addClass('sidebar-collapsed');
Trestle.cookie.set("trestle:sidebar", "collapsed");
} else if ($(document).width() >= 768) {
- sidebar.addClass('expanded');
+ body.addClass('sidebar-expanded');
Trestle.cookie.set("trestle:sidebar", "expanded");
}
});