github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/website/source/assets/javascripts/app/Sidebar.js (about)

     1  (function(){
     2  
     3    Sidebar = Base.extend({
     4  
     5      $body: null,
     6      $overlay: null,
     7      $sidebar: null,
     8      $sidebarHeader: null,
     9      $sidebarImg: null,
    10      $toggleButton: null,
    11  
    12      constructor: function(){
    13        this.$body = $('body');
    14        this.$overlay = $('.sidebar-overlay');
    15        this.$sidebar = $('#sidebar');
    16        this.$sidebarHeader = $('#sidebar .sidebar-header');
    17        this.$toggleButton = $('.navbar-toggle');
    18        this.sidebarImg = this.$sidebarHeader.css('background-image');
    19  
    20        this.addEventListeners();
    21      },
    22  
    23      addEventListeners: function(){
    24        var _this = this;
    25  
    26        _this.$toggleButton.on('click', function() {
    27          _this.$sidebar.toggleClass('open');
    28          if ((_this.$sidebar.hasClass('sidebar-fixed-left') || _this.$sidebar.hasClass('sidebar-fixed-right')) && _this.$sidebar.hasClass('open')) {
    29            _this.$overlay.addClass('active');
    30            _this.$body.css('overflow', 'hidden');
    31          } else {
    32            _this.$overlay.removeClass('active');
    33            _this.$body.css('overflow', 'auto');
    34          }
    35  
    36          return false;
    37        });
    38  
    39        _this.$overlay.on('click', function() {
    40          $(this).removeClass('active');
    41          _this.$body.css('overflow', 'auto');
    42          _this.$sidebar.removeClass('open');
    43        });
    44      }
    45  
    46    });
    47  
    48    window.Sidebar = Sidebar;
    49  
    50  })();