mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
29 lines
761 B
CoffeeScript
29 lines
761 B
CoffeeScript
define [
|
|
"libs/backbone"
|
|
"libs/mustache"
|
|
], () ->
|
|
FileViewManager = Backbone.View.extend
|
|
template: $("#fileViewTemplate").html()
|
|
className: "fullEditorArea"
|
|
id: "fileViewArea"
|
|
|
|
render: () ->
|
|
extension = @model.get("name").split(".").pop().toLowerCase()
|
|
image = (["jpg", "jpeg", "png", "gif", "eps", "pdf"].indexOf(extension) != -1)
|
|
html = Mustache.to_html(@template, {
|
|
name: @model.get("name")
|
|
downloadUrl: @model.downloadUrl()
|
|
previewUrl: @model.previewUrl()
|
|
image: image
|
|
})
|
|
@$el.html(html)
|
|
|
|
setModel: (model) ->
|
|
@model = model
|
|
@render()
|
|
@onResize()
|
|
|
|
onResize: () ->
|
|
@$("img").css
|
|
"max-width": ($("#fileViewArea").width() - 40) + "px"
|
|
"max-height": ($("#fileViewArea").height() - 140) + "px"
|