Sha256: 77a54da92f9425faaed22fa479071ba914bde218135002e643c02b13f6a22ff2

Contents?: true

Size: 807 Bytes

Versions: 9

Compression:

Stored size: 807 Bytes

Contents

// Represents an attachment object, which will contain an asset and any other
// fields the attachment is decorated with.
slices.Attachment = Backbone.Model.extend({

  // Initialize the attachment. Only thing of interest here is handling
  // the presence of files.
  initialize: function() {
    if (this.get('file')) {
      this.get('file').attachment = this;
      this.updateFileStatus();
    }
    if (this.get('asset') && this.get('asset').constructor !== slices.Asset) {
      this.set({ asset: new slices.Asset(this.get('asset')) });
    }
  },

  // Trigger normal change event when things happen with the file.
  updateFileStatus: function() {
    this.trigger('change');
  },

  toJSON: function() {
    var attrs = _.clone(this.attributes);
    delete attrs.asset;
    return attrs;
  }

});

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
slices-2.0.2 app/assets/javascripts/slices/app/models/attachment.js
slices-2.0.1 app/assets/javascripts/slices/app/models/attachment.js
slices-2.0.0 app/assets/javascripts/slices/app/models/attachment.js
slices-1.0.5 app/assets/javascripts/slices/app/models/attachment.js
slices-1.0.4 app/assets/javascripts/slices/app/models/attachment.js
slices-1.0.3 app/assets/javascripts/slices/app/models/attachment.js
slices-1.0.2 app/assets/javascripts/slices/app/models/attachment.js
slices-1.0.1 app/assets/javascripts/slices/app/models/attachment.js
slices-1.0.0 app/assets/javascripts/slices/app/models/attachment.js