BinaryFilesManager.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* eslint-disable
  2. max-len,
  3. no-unused-vars,
  4. */
  5. // TODO: This file was created by bulk-decaffeinate.
  6. // Fix any style issues and re-enable lint.
  7. /*
  8. * decaffeinate suggestions:
  9. * DS102: Remove unnecessary code created because of implicit returns
  10. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  11. */
  12. let BinaryFilesManager
  13. export default BinaryFilesManager = class BinaryFilesManager {
  14. constructor(ide, $scope) {
  15. this.ide = ide
  16. this.$scope = $scope
  17. this.$scope.$on('entity:selected', (event, entity) => {
  18. if (this.$scope.ui.view !== 'track-changes' && entity.type === 'file') {
  19. return this.openFile(entity)
  20. } else if (entity.type === 'doc') {
  21. return this.closeFile()
  22. }
  23. })
  24. }
  25. openFile(file) {
  26. this.ide.fileTreeManager.selectEntity(file)
  27. if (this.$scope.ui.view !== 'history') {
  28. this.$scope.ui.view = 'file'
  29. }
  30. this.$scope.openFile = null
  31. this.$scope.$apply()
  32. return window.setTimeout(
  33. () => {
  34. this.$scope.openFile = file
  35. this.$scope.$apply()
  36. this.$scope.$broadcast('file-view:file-opened')
  37. },
  38. 0,
  39. this
  40. )
  41. }
  42. closeFile() {
  43. return window.setTimeout(
  44. () => {
  45. this.$scope.openFile = null
  46. if (this.$scope.ui.view !== 'history') {
  47. this.$scope.ui.view = 'editor'
  48. }
  49. this.$scope.$apply()
  50. },
  51. 0,
  52. this
  53. )
  54. }
  55. }