terraform/website/source/assets/javascripts/app/_Sidebar.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2015-11-06 21:35:24 +01:00
(function(){
2015-11-07 06:01:14 +01:00
Sidebar = Base.extend({
$body: null,
$overlay: null,
$sidebar: null,
$sidebarHeader: null,
$sidebarImg: null,
$toggleButton: null,
constructor: function(){
this.$body = $('body');
this.$overlay = $('.sidebar-overlay');
this.$sidebar = $('#sidebar');
this.$sidebarHeader = $('#sidebar .sidebar-header');
this.$toggleButton = $('.navbar-toggle');
this.sidebarImg = this.$sidebarHeader.css('background-image');
this.addEventListeners();
},
addEventListeners: function(){
var _this = this;
_this.$toggleButton.on('click', function() {
_this.$sidebar.toggleClass('open');
if ((_this.$sidebar.hasClass('sidebar-fixed-left') || _this.$sidebar.hasClass('sidebar-fixed-right')) && _this.$sidebar.hasClass('open')) {
_this.$overlay.addClass('active');
_this.$body.css('overflow', 'hidden');
} else {
_this.$overlay.removeClass('active');
_this.$body.css('overflow', 'auto');
}
return false;
});
_this.$overlay.on('click', function() {
$(this).removeClass('active');
_this.$body.css('overflow', 'auto');
_this.$sidebar.removeClass('open');
});
}
});
window.Sidebar = Sidebar;
2015-11-06 21:35:24 +01:00
})();