 #
 
 # This silly line is the require line and the jQuery function start
-define ['jquery'], ($) -> $(document).ready ->
+define 'doc', ->
+  return document
 
-  # Cached jquery references
-  $body = $('body')
+define ['jquery', 'doc'], ($, doc) ->
 
-  # @todo
-  # $dismissables = $('[js-catbus-dismiss]')
-  # closeForDismissableClick = ->
-  #   if $catbusTail.is(':visible') and catbusOpen
-  #     closeCatbus()
-
-  $catbus     = $('[js-catbus]')
-  $catbusTail = $('[js-catbus-tail]')
-  $clickables = $catbusTail.add('[js-catbus-button]')
+  # jQuery Object References
+  $body            =
+  $catbus          =
+  $catbusTail      =
+  $clickables      = {}
 
   # Local storage constants
   LS_CATBUS_STATUS = 'catbus-status'
   LS_STORED_PINNED = 'pinned'
   LS_STORED_CLOSED = 'closed'
 
-  catbusOpen = $body.hasClass 'catbus-open'
+  # Other stuff.
+  catbusOpen       = false
 
   ###*
    * Tells us if local storage says the catbus is pinned open or not.


  ###*
   * You can't use CSS transitions through display states :(
   * @return {jQuery Object} $catbusTail
  ###
  toggleTail = ->
    $catbusTail.toggleClass 'hide', !catbusOpen


    newStatus = false

    if force is false or force is true
      newStatus = force
    else
      newStatus = !catbusOpen

    $body.toggleClass 'catbus-open', newStatus
    setLocalStorage newStatus
