2014-02-12 10:23:40 +00:00
|
|
|
define [
|
|
|
|
"libs/backbone"
|
2014-06-21 10:56:58 +00:00
|
|
|
"libs/mustache"
|
2014-02-12 10:23:40 +00:00
|
|
|
], () ->
|
|
|
|
FileViewManager = Backbone.View.extend
|
|
|
|
template: $("#fileViewTemplate").html()
|
|
|
|
className: "fullEditorArea"
|
|
|
|
id: "fileViewArea"
|
|
|
|
|
|
|
|
render: () ->
|
2014-05-21 16:44:30 +00:00
|
|
|
extension = @model.get("name").split(".").pop().toLowerCase()
|
2014-02-12 10:23:40 +00:00
|
|
|
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"
|