Sha256: 97826ea8057daecbf8f979a4fe1a31aa83ed805f6a40bb0c97d4cb8294709158

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

pageflow.HighlightedPage = pageflow.Object.extend({
  initialize: function(entryData) {
    this.entry = entryData;
  },

  getPagePermaId: function(currentPagePermaId) {
    var storylineId = this.entry.getStorylineIdByPagePermaId(currentPagePermaId);

    if (this.getNavigationBarMode(storylineId) === 'inherit_from_parent') {
      var parentPagePermaId = this.entry.getParentPagePermaId(storylineId);

      return parentPagePermaId &&
        this.getPagePermaId(parentPagePermaId);
    }
    else {
      return this.getDisplayedPageInChapter(currentPagePermaId);
    }
  },

  getDisplayedPageInChapter: function(pagePermaId) {
    return _(this.getChapterPagesUntil(pagePermaId).reverse()).find(function(permaId) {
      return this.pageIsDisplayedInNavigation(permaId);
    }, this);
  },

  pageIsDisplayedInNavigation: function(permaId) {
    return this.entry.getPageConfiguration(permaId).display_in_navigation !== false;
  },

  getNavigationBarMode: function(storylineId) {
    return this.entry.getStorylineConfiguration(storylineId).navigation_bar_mode;
  },

  getChapterPagesUntil: function(pagePermaId) {
    var found = false;
    var chapterId = this.entry.getChapterIdByPagePermaId(pagePermaId);

    return _.filter(this.entry.getChapterPagePermaIds(chapterId), function(other) {
      var result = !found;
      found = found || (pagePermaId === other);
      return result;
    });
  }
});

pageflow.HighlightedPage.create = function() {
  return new pageflow.HighlightedPage(pageflow.entryData);
};

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pageflow-0.10.0 app/assets/javascripts/pageflow/highlighted_page.js