You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.4 KiB

  1. /*
  2. * Copyright (c) 2014
  3. *
  4. * This file is licensed under the Affero General Public License version 3
  5. * or later.
  6. *
  7. * See the COPYING-README file.
  8. *
  9. */
  10. OCA.Trashbin = {};
  11. OCA.Trashbin.App = {
  12. _initialized: false,
  13. initialize: function($el) {
  14. if (this._initialized) {
  15. return;
  16. }
  17. this._initialized = true;
  18. this.fileList = new OCA.Trashbin.FileList(
  19. $('#app-content-trashbin'), {
  20. scrollContainer: $('#app-content'),
  21. fileActions: this._createFileActions()
  22. }
  23. );
  24. },
  25. _createFileActions: function() {
  26. var fileActions = new OCA.Files.FileActions();
  27. fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) {
  28. var dir = context.fileList.getCurrentDirectory();
  29. if (dir !== '/') {
  30. dir = dir + '/';
  31. }
  32. context.fileList.changeDirectory(dir + filename);
  33. });
  34. fileActions.setDefault('dir', 'Open');
  35. fileActions.register('all', 'Restore', OC.PERMISSION_READ, OC.imagePath('core', 'actions/history'), function(filename, context) {
  36. var fileList = context.fileList;
  37. var tr = fileList.findFileEl(filename);
  38. var deleteAction = tr.children("td.date").children(".action.delete");
  39. deleteAction.removeClass('delete-icon').addClass('progress-icon');
  40. fileList.disableActions();
  41. $.post(OC.filePath('files_trashbin', 'ajax', 'undelete.php'), {
  42. files: JSON.stringify([filename]),
  43. dir: fileList.getCurrentDirectory()
  44. },
  45. _.bind(fileList._removeCallback, fileList)
  46. );
  47. }, t('files_trashbin', 'Restore'));
  48. fileActions.register('all', 'Delete', OC.PERMISSION_READ, function() {
  49. return OC.imagePath('core', 'actions/delete');
  50. }, function(filename, context) {
  51. var fileList = context.fileList;
  52. $('.tipsy').remove();
  53. var tr = fileList.findFileEl(filename);
  54. var deleteAction = tr.children("td.date").children(".action.delete");
  55. deleteAction.removeClass('delete-icon').addClass('progress-icon');
  56. fileList.disableActions();
  57. $.post(OC.filePath('files_trashbin', 'ajax', 'delete.php'), {
  58. files: JSON.stringify([filename]),
  59. dir: fileList.getCurrentDirectory()
  60. },
  61. _.bind(fileList._removeCallback, fileList)
  62. );
  63. });
  64. return fileActions;
  65. }
  66. };
  67. $(document).ready(function() {
  68. $('#app-content-trashbin').one('show', function() {
  69. var App = OCA.Trashbin.App;
  70. App.initialize($('#app-content-trashbin'));
  71. // force breadcrumb init
  72. // App.fileList.changeDirectory(App.fileList.getCurrentDirectory(), false, true);
  73. });
  74. });