     if @currentTime < 0
       @currentTime = 0
 
-
 # Dashboard loaded and ready
 Dashing.on 'ready', ->
+  window.SwitcherControls = SwitcherControls
   # If multiple widgets per list item, switch them periodically
   $('.gridster li').each (index, listItem) ->
     $listItem = $(listItem)


    # If timer is complete, trigger alert
    if @currentTime is 0
      @$timer.stop()
      @resetCountdown()
      return


#   - show the name of the next dashboard
#   - add controls for manually cycling through dashboards
class SwitcherControls
  arrowContent = "&#65515;"
  stopTimerContent = "stop timer"

  constructor: (interval=60000, nextDashboardName) ->
    @currentTime = parseInt(interval, 10)
    @interval = parseInt(interval, 10)
    @$elements = $('#dc-switcher-controls')
    @nextDashboardName = nextDashboardName
    @incrementTime = 1000 # refresh every 1000 milliseconds
    @arrowContent = @$elements.data('arrow-content') || SwitcherControls.arrowContent
    @stopTimerContent = @$elements.data('stop-timer-content') || SwitcherControls.stopTimerContent
    @

  present: () ->
    @$elements.length
