Sha256: 1ab40a2254cb51117b264c653051a0dd8ee64c3855ba9b5f7819d67ba811e85d

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

pageflow.SeedEntryData = pageflow.EntryData.extend({
  initialize: function(options) {
    this.theming = options.theming;

    this.chapterConfigurations = options.chapter_configurations;

    this.chapterPagePermaIds = _(options.pages).reduce(function(memo, page) {
      memo[page.chapter_id] = memo[page.chapter_id] || [];
      memo[page.chapter_id].push(page.perma_id);
      return memo;
    }, {});

    this.chapterIdsByPagePermaIds = _(options.pages).reduce(function(memo, page) {
      memo[page.perma_id] = page.chapter_id;
      return memo;
    }, {});

    this.pageConfigurations = _.reduce(options.pages, function(memo, page) {
      memo[page.perma_id] = page.configuration;
      return memo;
    }, {});
  },

  getThemingOption: function(name) {
    return this.theming[name];
  },

  getChapterConfiguration: function(id) {
    return this.chapterConfigurations[id] || {};
  },

  getChapterPagePermaIds: function(id) {
    return this.chapterPagePermaIds[id];
  },

  getPageConfiguration: function(permaId) {
    return this.pageConfigurations[permaId] || {};
  },

  getChapterIdByPagePermaId: function(permaId) {
    return this.chapterIdsByPagePermaIds[permaId];
  }
});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pageflow-0.9.2 app/assets/javascripts/pageflow/seed_entry_data.js
pageflow-0.9.1 app/assets/javascripts/pageflow/seed_entry_data.js
pageflow-0.9.0 app/assets/javascripts/pageflow/seed_entry_data.js