Sha256: f830c2ad3f43c4dd9d4a3321140114cfff23f3627a2edcbde2b51d5fecf09342

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

pageflow.sitemap.Selection = Backbone.Model.extend({
  defaults: function() {
    return {
      storylines: [],
      pages: [],
      chapters: [],
      pageLinks: [],
      successorLinks: []
    };
  },

  contains: function(model) {
    return _(this.get('storylines')).contains(model) ||
      _(this.get('chapters')).contains(model) ||
      _(this.get('pages')).contains(model) ||
      _(this.get('pageLinks')).some(function(link) {
        return link === model |
          (link.id && link.id === model.id) ||
          (link.placeholder && link.placeholder === model.placeholder);
      }) ||
      _(this.get('successorLinks')).some(function(link) {
        return link.successor && link.successor === model.successor;
      });
  },

  select: function(name, models, options) {
    options = options || {};

    var base = options.additive ? this.get(name) : [];
    var attributes = this.defaults();

    attributes[name] = base.concat(models);
    this.set(attributes);

    this.trigger('select:' + name, attributes[name]);
  },

  reset: function() {
    this.select('pages', []);
  }
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pageflow-sitemap-1.5.0 app/assets/javascripts/pageflow/sitemap/editor/models/selection.js
pageflow-sitemap-1.4.0 app/assets/javascripts/pageflow/sitemap/editor/models/selection.js
pageflow-sitemap-1.3.0 app/assets/javascripts/pageflow/sitemap/editor/models/selection.js
pageflow-sitemap-1.2.0 app/assets/javascripts/pageflow/sitemap/editor/models/selection.js
pageflow-sitemap-1.1.0 app/assets/javascripts/pageflow/sitemap/editor/models/selection.js
pageflow-sitemap-1.0.0 app/assets/javascripts/pageflow/sitemap/editor/models/selection.js
pageflow-sitemap-0.1.0 app/assets/javascripts/pageflow/sitemap/editor/models/selection.js