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-13.0.0.beta4 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-13.0.0.beta3 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-13.0.0.beta2 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-13.0.0.beta1 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-12.2.0 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-12.1.0 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-12.0.4 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-12.0.3 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-12.0.2 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-12.0.1 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-12.0.0 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-12.0.0.rc7 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-12.0.0.rc6 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-0.11.4 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-12.0.0.rc5 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-12.0.0.rc4 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-12.0.0.rc3 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-12.0.0.rc2 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-12.0.0.rc1 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js
pageflow-0.11.3 app/assets/javascripts/pageflow/editor/views/file_thumbnail_view.js