diff options
Diffstat (limited to 'apps/files_trashbin')
-rw-r--r-- | apps/files_trashbin/js/app.js | 18 | ||||
-rw-r--r-- | apps/files_trashbin/js/filelist.js | 4 | ||||
-rw-r--r-- | apps/files_trashbin/tests/js/filelistSpec.js | 11 |
3 files changed, 17 insertions, 16 deletions
diff --git a/apps/files_trashbin/js/app.js b/apps/files_trashbin/js/app.js index cf3fb1d0d16..c59a132b8c4 100644 --- a/apps/files_trashbin/js/app.js +++ b/apps/files_trashbin/js/app.js @@ -19,22 +19,20 @@ OCA.Trashbin.App = { this._initialized = true; this.fileList = new OCA.Trashbin.FileList( $('#app-content-trashbin'), { - scrollContainer: $('#app-content') + scrollContainer: $('#app-content'), + fileActions: this._createFileActions() } ); - this.registerFileActions(this.fileList); }, - registerFileActions: function(fileList) { - var self = this; - var fileActions = _.extend({}, OCA.Files.FileActions); - fileActions.clear(); - fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename) { - var dir = fileList.getCurrentDirectory(); + _createFileActions: function() { + var fileActions = new OCA.Files.FileActions(); + fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) { + var dir = context.fileList.getCurrentDirectory(); if (dir !== '/') { dir = dir + '/'; } - fileList.changeDirectory(dir + filename); + context.fileList.changeDirectory(dir + filename); }); fileActions.setDefault('dir', 'Open'); @@ -69,7 +67,7 @@ OCA.Trashbin.App = { _.bind(fileList._removeCallback, fileList) ); }); - fileList.setFileActions(fileActions); + return fileActions; } }; diff --git a/apps/files_trashbin/js/filelist.js b/apps/files_trashbin/js/filelist.js index 205f879f335..826c1bd64d5 100644 --- a/apps/files_trashbin/js/filelist.js +++ b/apps/files_trashbin/js/filelist.js @@ -26,8 +26,8 @@ return name; } - var FileList = function($el) { - this.initialize($el); + var FileList = function($el, options) { + this.initialize($el, options); }; FileList.prototype = _.extend({}, OCA.Files.FileList.prototype, { id: 'trashbin', diff --git a/apps/files_trashbin/tests/js/filelistSpec.js b/apps/files_trashbin/tests/js/filelistSpec.js index d41c24c3cc9..11eeff68df8 100644 --- a/apps/files_trashbin/tests/js/filelistSpec.js +++ b/apps/files_trashbin/tests/js/filelistSpec.js @@ -21,7 +21,6 @@ describe('OCA.Trashbin.FileList tests', function() { var testFiles, alertStub, notificationStub, fileList; - var FileActions = OCA.Files.FileActions; beforeEach(function() { alertStub = sinon.stub(OC.dialogs, 'alert'); @@ -87,14 +86,18 @@ describe('OCA.Trashbin.FileList tests', function() { etag: '456' }]; - fileList = new OCA.Trashbin.FileList($('#app-content-trashbin')); - OCA.Trashbin.App.registerFileActions(fileList); + // register file actions like the trashbin App does + var fileActions = OCA.Trashbin.App._createFileActions(fileList); + fileList = new OCA.Trashbin.FileList( + $('#app-content-trashbin'), { + fileActions: fileActions + } + ); }); afterEach(function() { testFiles = undefined; fileList = undefined; - FileActions.clear(); $('#dir').remove(); notificationStub.restore(); alertStub.restore(); |