overleaf/services/web/public/coffee/history/VersionDetailView.coffee
2014-02-12 10:23:40 +00:00

28 lines
670 B
CoffeeScript

define [
"./util"
"history/FileDiff"
"history/FileDiffView"
"libs/mustache"
"libs/backbone"
], (util, FileDiff, FileDiffView)->
VersionView = Backbone.View.extend
template : $("#diffTemplate").html()
render: ->
html = Mustache.to_html(@template, @modelView())
@$el = $("#diffViewArea")
@$el.empty()
@$el.append html
for fileDiff in @model.get("file_diffs")
model = new FileDiff(_.extend(fileDiff, version_id: @model.get("id")))
view = new FileDiffView model: model
@$el.append view.render().el
return this
modelView: ->
modelView = @model.toJSON()
modelView.date = util.formatDate(modelView.date)
return modelView