Sha256: bb6221fa8d71d9db036a1f3880ac26b70d04fb296b46ccf7f892cf10e7ec70d0

Contents?: true

Size: 1.12 KB

Versions: 58

Compression:

Stored size: 1.12 KB

Contents

pageflow.TableRowView = Backbone.Marionette.View.extend({
  tagName: 'tr',

  events: {
    'click': function() {
      if (this.options.selection) {
        this.options.selection.set(
          this.selectionAttribute(),
          this.model
        );
      }
    }
  },

  initialize: function() {
    if (this.options.selection) {
      this.listenTo(this.options.selection, 'change', this.updateClassName);
    }
  },

  render: function() {
    _(this.options.columns).each(function(column) {
      this.appendSubview(new column.cellView(_.extend({
        model: this.model,
        column: column,
        attributeTranslationKeyPrefixes: this.options.attributeTranslationKeyPrefixes
      }, column.cellViewOptions || {})));
    }, this);

    this.updateClassName();

    return this;
  },

  updateClassName: function() {
    this.$el.toggleClass('is_selected', this.isSelected());
  },

  isSelected: function() {
    return this.options.selection &&
      this.options.selection.get(this.selectionAttribute()) === this.model;
  },

  selectionAttribute: function() {
    return this.options.selectionAttribute || 'current';
  }
});

Version data entries

58 entries across 58 versions & 1 rubygems

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