Sha256: ada3a3d17d1ffdd3216d76664a101e39f00836d98d1e2cfbc5e0d30f6000f5c0

Contents?: true

Size: 1.52 KB

Versions: 9

Compression:

Stored size: 1.52 KB

Contents

pageflow.UploadedFile = Backbone.Model.extend({
  mixins: [pageflow.stageProvider, pageflow.retryable],

  urlRoot: function() {
    return this.isNew() ? this.collection.url() : '/editor/files/' + this.fileType().collectionName;
  },

  fileType: function() {
    return this.collection && this.collection.fileType;
  },

  title: function() {
    return this.get('file_name');
  },

  thumbnailFile: function() {
    return this;
  },

  isUploading: function() {
    return this.get('state') === 'uploading';
  },

  isUploaded: function() {
    return this.get('state') !== 'uploading' && this.get('state') !== 'upload_failed';
  },

  isPending: function() {
    return !this.isReady() && !this.isFailed();
  },

  isReady: function() {
    return this.get('state') === this.readyState;
  },

  isFailed: function() {
    return this.get('state') && !!this.get('state').match(/_failed$/);
  },

  isRetryable: function() {
    return !!this.get('retryable');
  },

  isConfirmable: function() {
    return false;
  },

  isPositionable: function() {
    return false;
  },

  cancelUpload: function() {
    if (this.get('state') === 'uploading') {
      this.trigger('uploadCancelled');
      this.destroy();
    }
  },

  uploadFailed: function() {
    this.set('state', 'upload_failed');
    this.unset('uploading_progress');

    this.trigger('uploadFailed');
  },

  destroyUsage: function() {
    var usage = new pageflow.FileUsage({id: this.get('usage_id')});

    usage.destroy();

    this.trigger('destroy', this, this.collection, {});
  }
});

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pageflow-0.11.4 app/assets/javascripts/pageflow/editor/models/uploaded_file.js
pageflow-0.11.3 app/assets/javascripts/pageflow/editor/models/uploaded_file.js
pageflow-0.11.2 app/assets/javascripts/pageflow/editor/models/uploaded_file.js
pageflow-0.11.1 app/assets/javascripts/pageflow/editor/models/uploaded_file.js
pageflow-0.11.0 app/assets/javascripts/pageflow/editor/models/uploaded_file.js
pageflow-0.10.0 app/assets/javascripts/pageflow/editor/models/uploaded_file.js
pageflow-0.9.2 app/assets/javascripts/pageflow/editor/models/uploaded_file.js
pageflow-0.9.1 app/assets/javascripts/pageflow/editor/models/uploaded_file.js
pageflow-0.9.0 app/assets/javascripts/pageflow/editor/models/uploaded_file.js