Permalink
Browse files

file view/template is table row

file model can calculate original url
file model can destroy itself from view
  • Loading branch information...
1 parent 6bf0a93 commit a43639093ab5ff169d653ccb755087300c29a621 @shelling committed Dec 6, 2012
@@ -8,6 +8,8 @@
$(document).ready(function() {
+ $.ajaxSetup({ cache: false });
+
var FU = $("#fileupload");
FU.fileupload({
@@ -1,4 +1,13 @@
DropboxIO.Model.File = Backbone.Model.extend({
initialize: function() {
},
+ idAttribute: "mogkey",
+ urlRoot: "/file",
+ info: function() {
+ if (this.get("mogkey")) {
+ return _.extend( this.toJSON(), {
+ original: this.url() + "/original"
+ });
+ }
+ }
});
@@ -2,10 +2,26 @@ DropboxIO.View.File = Backbone.View.extend({
initialize: function() {
$(".filelist").append(this.$el);
},
- tagName: "li",
+ tagName: "tr",
+ events: {
+ "click a.close": "destroy",
+ },
+ destroy: function(e) {
+ e.preventDefault();
+ var that = this;
+ this.model.destroy({
+ success: function(model, response) {
+ that.$("td").fadeOut(1000, function() {
+ that.remove();
+ });
+ },
+ error: function(model, xhr) {
+ }
+ });
+ },
render: function() {
this.$el.html(
- DropboxIO.Template["file"](this.model.toJSON())
+ DropboxIO.Template["file"](this.model.info())
);
}
});
@@ -1 +1,6 @@
-{{ filename }}
+%td
+ {{ filename }}
+ %a{href: "{{ original }}"}
+ %i.icon-download
+%td
+ %a.close= "×"

0 comments on commit a436390

Please sign in to comment.