     else
       btn.removeClass('fa-caret-down').addClass('fa-caret-up')
 
-  collapseOrNot: (panel, collapse) ->
+  modifyPanel: (panel, collapse) ->
     index = $('.panel.project-list').index(panel)
-    cookie = "panel-collapsed-#{index}"
+    cookie = @cookieNameForIndex(index)
     if collapse
       panel.addClass('collapsed')
       $.cookie(cookie, true, {expires: 1})

class UserSync

  constructor: (selector) ->
    @collapseButtons = $("#{selector} .collapse-btn")
    @panels = $("#{selector} .panel")
    @collapsePanelsIfNeededAtStart()

    @collapseButtons.click((ev) =>
      button = $(ev.target)
      panel = $(ev.target).parent().parent().parent().find('.panel')
      collapse = button.hasClass('fa-caret-up')
      @replaceButton(button, collapse)
      @collapseOrNot(panel, collapse)
    )

  replaceButton: (btn, collapse) ->
    if collapse

      panel.removeClass('collapsed').removeClass('no-transition')
      $.removeCookie(cookie)

  cookieNameForIndex: (index) ->
    "panel-collapsed-#{index}"

$(document).on 'ready page:load', ->
  new UserSync('.user-sync')