overleaf/services/web/public/coffee/file-view/FileViewManager.coffee

33 lines
642 B
CoffeeScript
Raw Normal View History

2014-02-12 10:23:40 +00:00
define [
"file-view/FileView"
], (FileView) ->
class FileViewManager
constructor: (@ide) ->
@view = new FileView()
@ide.mainAreaManager.addArea
identifier: "file"
element: @view.$el
$(window).resize () => @view.onResize()
@ide.layoutManager.on "resize", () => @view.onResize()
@view.onResize()
@bindToFileTreeEvents()
@enable()
bindToFileTreeEvents: () ->
@ide.fileTreeManager.on "open:file", (file) =>
if @enabled
@showFile(file)
2014-02-12 10:23:40 +00:00
showFile: (file) ->
@ide.mainAreaManager.change('file')
2014-02-12 10:23:40 +00:00
@view.setModel(file)
enable: () ->
@enabled = true
disable: () ->
@enabled = false