diff options
Diffstat (limited to 'public/assets/js/lib/views')
| -rw-r--r-- | public/assets/js/lib/views/details/comments.js | 1 | ||||
| -rw-r--r-- | public/assets/js/lib/views/details/files.js | 9 | ||||
| -rw-r--r-- | public/assets/js/lib/views/details/gallery.js | 47 | ||||
| -rw-r--r-- | public/assets/js/lib/views/details/index.js | 2 |
4 files changed, 54 insertions, 5 deletions
diff --git a/public/assets/js/lib/views/details/comments.js b/public/assets/js/lib/views/details/comments.js index 819daba..4bd2eb7 100644 --- a/public/assets/js/lib/views/details/comments.js +++ b/public/assets/js/lib/views/details/comments.js @@ -17,6 +17,7 @@ var CommentsView = FormView.extend({ }, parse: function(comment){ + if (! comment.comment.length) return "" var datetime = verbose_date(comment.date, true) var t = this.template.replace(/{{username}}/g, comment.username) .replace(/{{comment}}/g, tidy_urls(comment.comment)) diff --git a/public/assets/js/lib/views/details/files.js b/public/assets/js/lib/views/details/files.js index 399d8a7..295b26c 100644 --- a/public/assets/js/lib/views/details/files.js +++ b/public/assets/js/lib/views/details/files.js @@ -18,6 +18,9 @@ var FilesView = FormView.extend({ } var total = 0, has_music = false files.forEach(function(file){ + if (is_image(file.filename)) { + return + } this.appendFile(file) total += file.size has_music = has_music || file.filename.match(/(mp3|wav|ogg)/i) @@ -37,11 +40,7 @@ var FilesView = FormView.extend({ var size = hush_size(file.size) var datetime = verbose_date(file.date, true) var date_class = carbon_date(file.date) - - var link = file.filename - if (link.indexOf("http") !== 0) { - link = "//carbonpictures.com/bucky/data/" + file.thread + "/" + file.filename - } + var link = make_link(file) var t = this.template.replace(/{{username}}/g, file.username) .replace(/{{link}}/g, link) 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 diff --git a/public/assets/js/lib/views/details/index.js b/public/assets/js/lib/views/details/index.js index e2adb55..d7fb26f 100644 --- a/public/assets/js/lib/views/details/index.js +++ b/public/assets/js/lib/views/details/index.js @@ -8,6 +8,7 @@ var DetailsView = View.extend({ initialize: function(opt){ this.comments = new CommentsView ({ parent: this }) this.files = new FilesView ({ parent: this }) + this.gallery = new GalleryView ({ parent: this }) }, load: function(id){ @@ -19,6 +20,7 @@ var DetailsView = View.extend({ $("h1").html(data.thread.title) this.comments.load(data.comments) this.files.load(data.files) + this.gallery.load(data.files) }, success: function(){ |
