Sha256: 5caad998f60f9ed5373bce933c8d7895504852bfab613bdc701f520f064d8656

Contents?: true

Size: 1.53 KB

Versions: 79

Compression:

Stored size: 1.53 KB

Contents

pageflow.FileThumbnailView = Backbone.Marionette.ItemView.extend({
  className: 'file_thumbnail',
  template: 'templates/file_thumbnail',

  modelEvents: {
    'change:state': 'update'
  },

  ui: {
    pictogram: '.pictogram'
  },

  onRender: function() {
    this.update();
  },

  update: function() {
    if (this.model) {
      var stage = this.model.currentStage();

      if (stage) {
        this.setStageClassName(stage.get('name'));
        this.ui.pictogram.toggleClass('action_required', stage.get('action_required'));
        this.ui.pictogram.toggleClass('failed', stage.get('failed'));
      }
      else {
        this.ui.pictogram.removeClass(this.model.stages.pluck('name').join(' '));
      }

      this.ui.pictogram.addClass(this.model.thumbnailPictogram);
      this.$el.css('background-image', this._imageUrl() ? 'url(' + this._imageUrl() + ')' : '');
      this.$el
        .removeClass('empty')
        .toggleClass('always_picogram', !!this.model.thumbnailPictogram)
        .toggleClass('ready', this.model.isReady());
    }
    else {
      this.$el.css('background-image', '');
      this.$el.removeClass('ready');
      this.ui.pictogram.addClass('empty');
    }
  },

  setStageClassName: function(name) {
    if (!this.$el.hasClass(name)) {
      this.ui.pictogram.removeClass('empty');
      this.ui.pictogram.removeClass(this.model.stages.pluck('name').join(' '));
      this.ui.pictogram.addClass(name);
    }
  },

  _imageUrl: function() {
    return this.model.get(this.options.imageUrlPropertyName || 'thumbnail_url');
  }
});

Version data entries

79 entries across 79 versions & 1 rubygems

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