summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views/details/gallery.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/js/lib/views/details/gallery.js')
-rw-r--r--public/assets/js/lib/views/details/gallery.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/public/assets/js/lib/views/details/gallery.js b/public/assets/js/lib/views/details/gallery.js
new file mode 100644
index 0000000..da6e97f
--- /dev/null
+++ b/public/assets/js/lib/views/details/gallery.js
@@ -0,0 +1,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)
+ },
+
+}) \ No newline at end of file