       $.post(window.routes.remove_files_path.replace('/:path', item.data('path')), {
         _method: 'delete'
       }).success (d) ->
-        window.available_undos = [d]
+        window.available_undos.unshift d
         load_file_list item.closest('ul.column')
       .error ->
         update_footer -2

    if window.available_undos.length > 0
      undo = window.available_undos[0].undo
      $.post(undo.action, undo.parameters)
      .success ->
        window.available_undos = window.available_undos.splice(1)
        load_file_list window.selected_items[0].find('ul.column')
      .error ->
        update_footer -3

  menu_items =
    for_files: ['Open--','Move to Trash--','Get Info','Rename'],


  menu_items_clicked =
    for_files: [null, move_to_trash, null, null],
    for_lists: [undo, refresh, null, null],

  $(document).bind 'contextmenu', (e) ->
    if $('#context_menu').css('z-index') != '0'
