2014-03-05 12:55:47 -05:00
|
|
|
define [
|
|
|
|
"track-changes/models/ChangeList"
|
2014-03-06 09:08:12 -05:00
|
|
|
"track-changes/models/Diff"
|
2014-03-05 12:55:47 -05:00
|
|
|
"track-changes/ChangeListView"
|
2014-03-06 09:08:12 -05:00
|
|
|
"track-changes/DiffView"
|
|
|
|
], (ChangeList, Diff, ChangeListView, DiffView) ->
|
2014-03-05 12:55:47 -05:00
|
|
|
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()
|
|
|
|
|
2014-03-05 12:55:47 -05:00
|
|
|
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)
|
2014-03-05 12:55:47 -05:00
|
|
|
|
|
|
|
@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()
|
|
|
|
|
2014-03-05 12:55:47 -05:00
|
|
|
@showEl()
|
|
|
|
|
|
|
|
showEl: ->
|
|
|
|
@ide.editor.hide()
|
|
|
|
@$el.show()
|
|
|
|
|
|
|
|
hideEl: () ->
|
|
|
|
@ide.editor.show()
|
|
|
|
@$el.hide()
|
|
|
|
|
|
|
|
return TrackChangesManager
|