gotoplugin.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
  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. (function (OCA) {
  11. OCA.Files = OCA.Files || {};
  12. /**
  13. * @namespace OCA.Files.GotoPlugin
  14. *
  15. */
  16. OCA.Files.GotoPlugin = {
  17. name: 'Goto',
  18. disallowedLists: [
  19. 'files',
  20. 'trashbin'
  21. ],
  22. attach: function (fileList) {
  23. if (this.disallowedLists.indexOf(fileList.id) !== -1) {
  24. return;
  25. }
  26. var fileActions = fileList.fileActions;
  27. fileActions.registerAction({
  28. name: 'Goto',
  29. displayName: t('files', 'View in folder'),
  30. mime: 'all',
  31. permissions: OC.PERMISSION_ALL,
  32. iconClass: 'icon-goto nav-icon-extstoragemounts',
  33. type: OCA.Files.FileActions.TYPE_DROPDOWN,
  34. actionHandler: function (fileName, context) {
  35. var fileModel = context.fileInfoModel;
  36. OC.Apps.hideAppSidebar($('.detailsView'));
  37. OCA.Files.App.setActiveView('files', {silent: true});
  38. OCA.Files.App.fileList.changeDirectory(fileModel.get('path'), true, true).then(function() {
  39. OCA.Files.App.fileList.scrollTo(fileModel.get('name'));
  40. });
  41. },
  42. render: function (actionSpec, isDefault, context) {
  43. return fileActions._defaultRenderAction.call(fileActions, actionSpec, isDefault, context)
  44. .removeClass('permanent');
  45. }
  46. });
  47. }
  48. };
  49. })(OCA);
  50. OC.Plugins.register('OCA.Files.FileList', OCA.Files.GotoPlugin);