BigW Consortium Gitlab

sidebar.js.coffee 739 Bytes
Newer Older
Job van der Voort committed
1 2 3
responsive_resize = ->
  current_width = $(window).width()
  if current_width < 985
4
    $('.responsive-side').addClass("ui right wide sidebar")
Job van der Voort committed
5
  else
6
    $('.responsive-side').removeClass("ui right wide sidebar")
Job van der Voort committed
7 8

$ ->
9
  # Depending on window size, set the sidebar offscreen.
Job van der Voort committed
10 11 12 13 14 15 16 17 18 19 20 21 22
  responsive_resize()

  $('.sidebar-expand-button').click ->
    $('.ui.sidebar')
      .sidebar({overlay: true})
      .sidebar('toggle')

  # Hide sidebar on click outside of sidebar
  $(document).mouseup (e) ->
    container = $(".ui.sidebar")
    container.sidebar "hide"  if not container.is(e.target) and container.has(e.target).length is 0
    return

23
# On resize, check if sidebar should be offscreen.
Job van der Voort committed
24 25 26
$(window).resize ->
  responsive_resize()
  return