Sha256: 7b3c384aeb6c3eb3514811ad928877a2a11c9290f0f5da4ea69a6dd8090b4a2a

Contents?: true

Size: 1.91 KB

Versions: 58

Compression:

Stored size: 1.91 KB

Contents

/**
 * A generic list view with items consisting of a thumbnail, text and
 * possibly some buttons or a navigation arrow.
 *
 * Models inside the collection must implement the following methods:
 *
 * @param {Backbone.Collection} options.collection
 *
 * @param {string} options.label
 *   Text of the label to display above the list.
 *
 * @param {boolean} [options.highlight=false]
 *
 * @param {boolean} [options.sortable=false]
 *
 * @param {string|function} [options.itemDescription]
 *
 * @param {string|function} [options.itemTypeName]
 *
 * @param {string|function} [options.itemTypeDescription]
 *
 * @param {string|function} [options.itemIsInvalid]
 *
 * @param {function} [options.onEdit]
 *
 * @param {function} [options.onRemove]
 *
 * @class
 * @memberof module:pageflow/editor
 */
pageflow.ListView = Backbone.Marionette.ItemView.extend({
  template: 'pageflow/editor/templates/list',
  className: 'list',

  ui: {
    label: '.list_label',
    items: '.list_items'
  },

  onRender: function() {
    var collectionViewConstructor = this.options.sortable ?
      pageflow.SortableCollectionView :
      pageflow.CollectionView;

    this.subview(new collectionViewConstructor({
      el: this.ui.items,
      collection: this.collection,

      itemViewConstructor: pageflow.ListItemView,

      itemViewOptions: _.extend({
        description: this.options.itemDescription,
        typeName: this.options.itemTypeName,
        typeDescription: this.options.itemTypeDescription,
        isInvalid: this.options.itemIsInvalid
      }, _(this.options).pick('onEdit', 'onDelete', 'highlight')),

      blankSlateViewConstructor: Backbone.Marionette.ItemView.extend({
        tagName: 'li',
        className: 'list_blank_slate',
        template: 'pageflow/editor/templates/list_blank_slate'
      })
    }));

    this.ui.label.text(this.options.label);

    this.$el.toggleClass('with_type_pictogram', !!this.options.itemTypeName);
  }
});

Version data entries

58 entries across 58 versions & 1 rubygems

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