Sha256: f95dff2c712f36443a5240791138c7dfc0ecdc65c278dae081436e3d6395b4ff

Contents?: true

Size: 1.72 KB

Versions: 63

Compression:

Stored size: 1.72 KB

Contents

pageflow.HighlightedPage = pageflow.Object.extend({
  initialize: function(entryData, options) {
    this.customNavigationBarMode = options && options.customNavigationBarMode;
    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) {
    if (this.customNavigationBarMode) {
      return this.customNavigationBarMode(storylineId, this.entry);
    }
    else {
      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(options) {
  return new pageflow.HighlightedPage(pageflow.entryData, options);
};

Version data entries

63 entries across 63 versions & 1 rubygems

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