   'vendor/jquery.pageless'
   'vendor/jquery.scrollTo'
   'compiled/badge_counts'
-], ($, Backbone, helpDialog, tours) ->
+], ($, _, Backbone, helpDialog, tours) ->
   helpDialog.initTriggers()
   tours.init()
 

require [
  'jquery'

  # true modules that we manage in this file
  'Backbone'

  # new styles only - show and hide the courses vertical menu when the user clicks the hamburger button
  # This was in the courses bundle, but it sometimes needs to work in places that don't
  # load that bundle.
  #
  WIDE_BREAKPOINT = 1200

  setMenuItemTabIndex = ($menuElement) ->
    # in testing this, it seems that $(document).width() returns 15px less than what it should.
    if ($('body').hasClass('course-menu-expanded') || $(document).width() >= WIDE_BREAKPOINT - 15)
      $menuElement.attr('tabIndex', 0)
    else
      $menuElement.attr('tabIndex', -1)

  $(document).ready( ->
    return unless window.ENV.use_new_styles?

    $('#section-tabs li a').each((index, element) ->
      setMenuItemTabIndex($(element))
    )
  )

  if window.ENV.use_new_styles?
    $("body").on('click', '#courseMenuToggle', ->
      $("body").toggleClass("course-menu-expanded")
      $('#section-tabs li a').each((index, element) ->
        setMenuItemTabIndex($(element))
      )
    )

    $(window).on('resize', _.debounce( ->
      $('#section-tabs li a').each((index, element) ->
        setMenuItemTabIndex($(element))
      )
    , 50)
    )


  ##
  # Backbone routes
