Sha256: 851ccf49e0d6b5bd6ed421401223c30d2a82dafea7abbdb6b1ae141966edd0e5

Contents?: true

Size: 1.18 KB

Versions: 28

Compression:

Stored size: 1.18 KB

Contents

Locomotive.Views.Shared ||= {}

class Locomotive.Views.Shared.SidebarView extends Backbone.View

  el: 'body > .sidebar'

  initialize: ->
    _.bindAll(@, 'close_sidebar_on_mobile')

    @pages_view = new Locomotive.Views.Pages.ListView()

    @tokens = [
      PubSub.subscribe 'application_view.resize', @close_sidebar_on_mobile
    ]

  render: ->
    @pages_view.render()
    @collapse_in_sections()
    @close_sidebar_on_mobile()
    @highlight_active_section()

  highlight_active_section: ->
    if section = $(@el).data('current-section')
      @$(".sidebar-link.#{section}").addClass('is-active')

  toggle_sidebar: (event) ->
    if @is_sidebar_open() then @close_sidebar() else @show_sidebar()

  is_sidebar_open: ->
    $('body').hasClass('sidebar-open')

  show_sidebar: ->
    $('body').removeClass('sidebar-closed').addClass('sidebar-open')

  close_sidebar: ->
    $('body').removeClass('sidebar-open').addClass('sidebar-closed')

  close_sidebar_on_mobile: ->
    if @is_sidebar_open() && $(window).width() < 992
      @close_sidebar()

  collapse_in_sections: ->
    @$('a[data-toggle="collapse"].is-active').each ->
      target_id = $(this).attr('href')
      $(target_id).collapse('show')

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
locomotivecms-4.2.0.alpha2 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-4.2.0.alpha1 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-4.1.1 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-4.1.0 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-4.1.0.rc1 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-4.0.3 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-4.0.2 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-4.0.1 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-4.0.0 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-4.0.0.rc0 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-4.0.0.alpha3 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-3.4.1 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-4.0.0.alpha2 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-4.0.0.alpha1 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-3.4.0 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-3.3.0 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-3.3.0.rc3 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-3.3.0.rc2 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-3.1.2 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee
locomotivecms-3.2.1 app/assets/javascripts/locomotive/views/shared/sidebar_view.js.coffee