Sha256: 4cdf70ba348461f0efeea7ea2a3da9e87056cdb99755cca78b6bb9021a2b79d7

Contents?: true

Size: 1.15 KB

Versions: 49

Compression:

Stored size: 1.15 KB

Contents

pageflow.TextTrackFile = pageflow.HostedFile.extend({
  defaults: {
    configuration: {
      kind: 'captions'
    }
  },

  processingStages: [
    {
      name: 'processing',
      activeStates: ['processing'],
      failedStates: ['processing_failed']
    }
  ],

  readyState: 'processed',

  initialize: function(attributes, options) {
    pageflow.UploadedFile.prototype.initialize.apply(this, arguments);

    if (this.isNew() && !this.configuration.get('srclang')) {
      this.configuration.set('srclang', this.extractLanguageCodeFromFilename());
    }
  },

  displayLabel: function() {
    return this.configuration.get('label') ||
      this.inferredLabel() ||
      I18n.t('pageflow.editor.text_track_files.label_missing');
  },

  inferredLabel: function() {
    var srclang = this.configuration.get('srclang');

    if (srclang) {
      return I18n.t('pageflow.languages.' + srclang, {
        defaultValue: ''
      });
    }
  },

  extractLanguageCodeFromFilename: function() {
    var matches = /\S+\.([a-z]{2})_[A-Z]{2}\.[a-z]+/.exec(this.get('file_name'));
    return matches && matches[1];
  }
});

pageflow.TextTrackFile.displayLabelBinding = 'srclang';

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
pageflow-12.6.0 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-13.1.0 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-12.5.0 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-12.4.1 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-13.0.0 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-13.0.0.rc1 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-12.4.0 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-12.3.0 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-13.0.0.beta7 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-13.0.0.beta6 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-13.0.0.beta5 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-13.0.0.beta4 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-13.0.0.beta3 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-13.0.0.beta2 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-13.0.0.beta1 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-12.2.0 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-12.1.0 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-12.0.4 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-12.0.3 app/assets/javascripts/pageflow/editor/models/text_track_file.js
pageflow-12.0.2 app/assets/javascripts/pageflow/editor/models/text_track_file.js