Sha256: 3f9acb4765f21e2dc1f8a95f66e560e5dd093e39b203332202500d18feac9691

Contents?: true

Size: 1.28 KB

Versions: 46

Compression:

Stored size: 1.28 KB

Contents

pageflow.WidgetItemView = Backbone.Marionette.Layout.extend({
  template: 'templates/widget_item',
  tagName: 'li',
  className: 'widget_item',

  regions: {
    widgetTypeContainer: '.widget_type'
  },

  ui: {
    role: 'h2'
  },

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

  events: {
    'click .settings': function() {
      pageflow.editor.navigate('/widgets/' + this.model.role(), {trigger: true});
      return false;
    },
  },

  onRender: function() {
    var widgetTypes = this.options.widgetTypes.findAllByRole(this.model.role()) || [];
    var isOptional = this.options.widgetTypes.isOptional(this.model.role());

    this.widgetTypeContainer.show(new pageflow.SelectInputView({
      model: this.model,
      propertyName: 'type_name',
      label: I18n.t('pageflow.widgets.roles.' + this.model.role()),
      collection: widgetTypes,
      valueProperty: 'name',
      translationKeyProperty: 'translationKey',
      includeBlank: isOptional || !this.model.get('type_name')
    }));

    this.$el.toggleClass('is_hidden', widgetTypes.length <= 1 &&
                         !this.model.hasConfiguration() &&
                         !isOptional);

    this.update();
  },

  update: function() {
    this.$el.toggleClass('has_settings', this.model.hasConfiguration());
  }
});

Version data entries

46 entries across 46 versions & 1 rubygems

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