Sha256: 5249dc67bc74c0c23be299f979760120dcf8efc543a98d5014aec0e2aa88409f

Contents?: true

Size: 1.84 KB

Versions: 76

Compression:

Stored size: 1.84 KB

Contents

pageflow.EncodingConfirmation = Backbone.Model.extend({
  paramRoot: 'encoding_confirmation',

  initialize: function() {
    this.videoFiles = new Backbone.Collection();
    this.audioFiles = new Backbone.Collection();

    this.updateEmpty();
    this.watchCollections();
  },

  watchCollections: function() {
    this.listenTo(this.videoFiles, 'add remove', this.check);
    this.listenTo(this.audioFiles, 'add remove', this.check);

    this.listenTo(this.videoFiles, 'reset', this.updateEmpty);
    this.listenTo(this.audioFiles, 'reset', this.updateEmpty);
  },

  check: function() {
    var model = this;

    model.updateEmpty();
    model.set('checking', true);

    model.save({}, {
      url: model.url() + '/check',
      success: function() {
        model.set('checking', false);
      },
      error: function() {
        model.set('checking', false);
      }
    });
  },

  saveAndReset: function() {
    var model = this;

    model.save({}, {
      success: function() {
        model.set('summary_html', '');

        model.videoFiles.reset();
        model.audioFiles.reset();
      }
    });
  },

  updateEmpty: function() {
    this.set('empty', this.videoFiles.length === 0 && this.audioFiles.length === 0);
  },

  url: function() {
    return '/editor/entries/' + pageflow.entry.get('id') + '/encoding_confirmations';
  },

  toJSON: function() {
    return {
      video_file_ids: this.videoFiles.pluck('id'),
      audio_file_ids: this.audioFiles.pluck('id'),
    };
  }
});

pageflow.EncodingConfirmation.createWithPreselection = function(options) {
  var model = new pageflow.EncodingConfirmation();

  if (options.fileId) {
    if (options.fileType === 'video_file') {
      model.videoFiles.add(pageflow.videoFiles.get(options.fileId));
    }
    else {
      model.audioFiles.add(pageflow.audioFiles.get(options.fileId));
    }
  }

  return model;
};

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
pageflow-14.5.2 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-15.0.2 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-15.0.1 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-15.0.0 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-14.5.1 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-14.5.0 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-15.0.0.rc2 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-15.0.0.rc1 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-15.0.0.beta4 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-15.0.0.beta3 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-14.4.0 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-15.0.0.beta2 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-15.0.0.beta1 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-14.3.0 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-14.2.1 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-14.2.0 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-14.1.1 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-14.1.0 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-14.0.0 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js
pageflow-14.0.0.rc2 app/assets/javascripts/pageflow/editor/models/encoding_confirmation.js