blob: de9a6a43859999280aab0e1d4dc5f560fccd0199 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
var GalleryView = View.extend({
el: "#gallery",
events: {
},
initialize: function(){
this.__super__.initialize.call(this)
this.template = this.$(".template").html()
},
load: function(files){
if (! files.length) {
this.$el.hide()
}
files.forEach(function(file){
if (! is_image(file.filename)) {
return
}
this.appendFile(file)
}.bind(this))
},
parse: function(file){
var age = get_age(file.date)
var link = make_link(file)
var thumb = make_thumb(file)
var t = this.template.replace(/{{username}}/g, file.username)
.replace(/{{thumb}}/g, thumb)
.replace(/{{link}}/g, link)
.replace(/{{age}}/g, age)
var $t = $(t)
if (app.debug) {
$t.find('.date').append(', #' + file.id)
}
return $t
},
prependFile: function(file){
var $el = this.parse(file)
this.$el.prepend($el)
},
appendFile: function(file){
var $el = this.parse(file)
this.$el.append($el)
},
})
|