Sha256: 7728add6b31758cb0444ce799d1cfb2f5814cb37e6e93ad965d3fa3c5258ad78

Contents?: true

Size: 927 Bytes

Versions: 16

Compression:

Stored size: 927 Bytes

Contents

pageflow.Widget = Backbone.Model.extend({
  paramRoot: 'widget',
  i18nKey: 'pageflow/widget',

  initialize: function(attributes, options) {
    this.widgetTypes = options.widgetTypes;

    this.configuration = new pageflow.WidgetConfiguration(
      this.get('configuration') || {}
    );

    this.listenTo(this.configuration, 'change', function() {
      this.trigger('change:configuration', this);
    });
  },

  widgetType: function() {
    return this.get('type_name') && this.widgetTypes.findByName(this.get('type_name'));
  },

  hasConfiguration: function() {
    return !!(this.widgetType() && this.widgetType().hasConfiguration());
  },

  role: function() {
    return this.id;
  },

  urlRoot: function() {
    return this.collection.url();
  },

  toJSON: function() {
    return {
      role: this.role(),
      type_name: this.get('type_name'),
      configuration: this.configuration.toJSON()
    };
  },
});

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
pageflow-12.6.0 app/assets/javascripts/pageflow/editor/models/widget.js
pageflow-12.5.0 app/assets/javascripts/pageflow/editor/models/widget.js
pageflow-12.4.1 app/assets/javascripts/pageflow/editor/models/widget.js
pageflow-13.0.0 app/assets/javascripts/pageflow/editor/models/widget.js
pageflow-13.0.0.rc1 app/assets/javascripts/pageflow/editor/models/widget.js
pageflow-12.4.0 app/assets/javascripts/pageflow/editor/models/widget.js
pageflow-12.3.0 app/assets/javascripts/pageflow/editor/models/widget.js
pageflow-13.0.0.beta7 app/assets/javascripts/pageflow/editor/models/widget.js
pageflow-13.0.0.beta6 app/assets/javascripts/pageflow/editor/models/widget.js
pageflow-13.0.0.beta5 app/assets/javascripts/pageflow/editor/models/widget.js
pageflow-13.0.0.beta4 app/assets/javascripts/pageflow/editor/models/widget.js
pageflow-13.0.0.beta3 app/assets/javascripts/pageflow/editor/models/widget.js
pageflow-13.0.0.beta2 app/assets/javascripts/pageflow/editor/models/widget.js
pageflow-13.0.0.beta1 app/assets/javascripts/pageflow/editor/models/widget.js
pageflow-12.2.0 app/assets/javascripts/pageflow/editor/models/widget.js
pageflow-12.1.0 app/assets/javascripts/pageflow/editor/models/widget.js