2018-11-05 05:06:39 -05:00
|
|
|
/* eslint-disable
|
|
|
|
max-len,
|
|
|
|
no-unused-vars,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2020-05-19 05:02:56 -04:00
|
|
|
let BinaryFilesManager
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2020-12-15 05:23:54 -05:00
|
|
|
export default BinaryFilesManager = class BinaryFilesManager {
|
2020-05-19 05:02:56 -04:00
|
|
|
constructor(ide, $scope) {
|
|
|
|
this.ide = ide
|
|
|
|
this.$scope = $scope
|
|
|
|
this.$scope.$on('entity:selected', (event, entity) => {
|
|
|
|
if (this.$scope.ui.view !== 'track-changes' && entity.type === 'file') {
|
|
|
|
return this.openFile(entity)
|
2022-03-15 09:55:17 -04:00
|
|
|
} else if (entity.type === 'doc') {
|
|
|
|
return this.closeFile()
|
2020-05-19 05:02:56 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
openFile(file) {
|
2022-07-27 09:24:16 -04:00
|
|
|
if (this.$scope.ui.view === 'editor') {
|
|
|
|
// store position before switching to binary view
|
|
|
|
this.$scope.$broadcast('store-doc-position')
|
|
|
|
}
|
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
this.ide.fileTreeManager.selectEntity(file)
|
2022-05-09 07:03:50 -04:00
|
|
|
if (this.$scope.ui.view !== 'history') {
|
|
|
|
this.$scope.ui.view = 'file'
|
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
this.$scope.openFile = null
|
|
|
|
this.$scope.$apply()
|
|
|
|
return window.setTimeout(
|
|
|
|
() => {
|
|
|
|
this.$scope.openFile = file
|
2021-06-10 07:26:27 -04:00
|
|
|
|
|
|
|
this.$scope.$apply()
|
|
|
|
|
|
|
|
this.$scope.$broadcast('file-view:file-opened')
|
2022-11-08 11:45:19 -05:00
|
|
|
window.dispatchEvent(new Event('file-view:file-opened'))
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
|
|
|
0,
|
|
|
|
this
|
|
|
|
)
|
|
|
|
}
|
2022-03-15 09:55:17 -04:00
|
|
|
|
|
|
|
closeFile() {
|
|
|
|
return window.setTimeout(
|
|
|
|
() => {
|
|
|
|
this.$scope.openFile = null
|
2022-05-09 07:03:50 -04:00
|
|
|
if (this.$scope.ui.view !== 'history') {
|
|
|
|
this.$scope.ui.view = 'editor'
|
|
|
|
}
|
2022-03-15 09:55:17 -04:00
|
|
|
this.$scope.$apply()
|
|
|
|
},
|
|
|
|
0,
|
|
|
|
this
|
|
|
|
)
|
|
|
|
}
|
2020-12-15 05:23:54 -05:00
|
|
|
}
|