overleaf/services/web/public/coffee/track-changes/TrackChangesManager.coffee

58 lines
1.3 KiB
CoffeeScript
Raw Normal View History

define [
"track-changes/models/ChangeList"
2014-03-06 09:08:12 -05:00
"track-changes/models/Diff"
"track-changes/ChangeListView"
2014-03-06 09:08:12 -05:00
"track-changes/DiffView"
], (ChangeList, Diff, ChangeListView, DiffView) ->
class TrackChangesManager
template: $("#trackChangesPanelTemplate").html()
constructor: (@ide) ->
@$el = $(@template)
$("#editorWrapper").append(@$el)
@hideEl()
2014-03-07 08:05:59 -05:00
@ide.editor.on "change:doc", () =>
@hideEl()
@$el.find(".track-changes-close").on "click", (e) =>
e.preventDefault
@hideEl()
show: () ->
2014-03-06 09:08:12 -05:00
@project_id = window.userSettings.project_id
@doc_id = @ide.editor.current_doc_id
@changes = new ChangeList([], doc_id: @doc_id, project_id: @project_id)
@changeListView = new ChangeListView(
collection : @changes,
el : @$el.find(".change-list-area")
)
@changeListView.render()
@changeListView.loadUntilFull()
2014-03-06 11:32:18 -05:00
@changeListView.on "change_diff", (fromModel, toModel) =>
2014-03-06 09:08:12 -05:00
@diff = new Diff({
project_id: @project_id
doc_id: @doc_id
2014-03-06 11:32:18 -05:00
from: fromModel.get("version")
to: toModel.get("version")
2014-03-06 09:08:12 -05:00
})
@diffView = new DiffView(
model: @diff
el: @$el.find(".track-changes-diff")
)
@diff.fetch()
@showEl()
showEl: ->
@ide.editor.hide()
@$el.show()
hideEl: () ->
@ide.editor.show()
@$el.hide()
return TrackChangesManager