app.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
  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. if (!OCA.External) {
  11. /**
  12. * @namespace
  13. */
  14. OCA.External = {};
  15. }
  16. /**
  17. * @namespace
  18. */
  19. OCA.External.App = {
  20. fileList: null,
  21. initList: function($el) {
  22. if (this.fileList) {
  23. return this.fileList;
  24. }
  25. this.fileList = new OCA.External.FileList(
  26. $el,
  27. {
  28. scrollContainer: $('#app-content'),
  29. fileActions: this._createFileActions()
  30. }
  31. );
  32. this._extendFileList(this.fileList);
  33. this.fileList.appName = t('files_external', 'External storage');
  34. return this.fileList;
  35. },
  36. removeList: function() {
  37. if (this.fileList) {
  38. this.fileList.$fileList.empty();
  39. }
  40. },
  41. _createFileActions: function() {
  42. // inherit file actions from the files app
  43. var fileActions = new OCA.Files.FileActions();
  44. fileActions.registerDefaultActions();
  45. // when the user clicks on a folder, redirect to the corresponding
  46. // folder in the files app instead of opening it directly
  47. fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) {
  48. OCA.Files.App.setActiveView('files', {silent: true});
  49. OCA.Files.App.fileList.changeDirectory(context.$file.attr('data-path') + '/' + filename, true, true);
  50. });
  51. fileActions.setDefault('dir', 'Open');
  52. return fileActions;
  53. },
  54. _extendFileList: function(fileList) {
  55. // remove size column from summary
  56. fileList.fileSummary.$el.find('.filesize').remove();
  57. }
  58. };
  59. $(document).ready(function() {
  60. $('#app-content-extstoragemounts').on('show', function(e) {
  61. OCA.External.App.initList($(e.target));
  62. });
  63. $('#app-content-extstoragemounts').on('hide', function() {
  64. OCA.External.App.removeList();
  65. });
  66. });