-contextController = null
+window.contextController = null
 
 $(document).ready ->
-  contextController = new ContextController('#contextPanel')
+  window.contextController = new ContextController('#contextPanel')
 
 class ContextController
   constructor: (containerSelector) ->

    @$container.find('.cancel').click (event) =>
      @contextView.showProfile()
    
    $(containerSelector).find('.context, .profile').click (event) =>
      if @contextView.profileState() is 'none'
        @contextView.expandProfile()
      else
        @contextView.contractProfile()
    
    $('form#update_profile').bind 'ajax:beforeSend', (xhr, settings)=>
      @contextView.showProfile()

    
    $('form#update_profile').bind 'ajax:error', (xhr, status, error)->
      $('p.alert').text(error)
  toggleProfile:  ->
    if @contextView.profileState() is 'none'
      @contextView.expandProfile()
    else
      @contextView.contractProfile()

class ContextView
  constructor: (containerSelector) ->
