blob: da6e97f1fbd9ac367680561d62ad9b4534793f21 (
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
|
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)
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)
},
})
|