1
0

gotoplugin.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. OCA.Files.App.setActiveView('files', {silent: true});
  37. OCA.Files.App.fileList.changeDirectory(fileModel.get('path'), true, true).then(function() {
  38. OCA.Files.App.fileList.scrollTo(fileModel.get('name'));
  39. });
  40. },
  41. render: function (actionSpec, isDefault, context) {
  42. return fileActions._defaultRenderAction.call(fileActions, actionSpec, isDefault, context)
  43. .removeClass('permanent');
  44. }
  45. });
  46. }
  47. };
  48. })(OCA);
  49. OC.Plugins.register('OCA.Files.FileList', OCA.Files.GotoPlugin);