Skip to content

Instantly share code, notes, and snippets.

@documentcloud
Created December 16, 2009 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save documentcloud/258105 to your computer and use it in GitHub Desktop.
Save documentcloud/258105 to your computer and use it in GitHub Desktop.
/////////////////////////////////////////////////////////////////////////////
// The public DocumentViewer API. Available for other scripts to access:
/////////////////////////////////////////////////////////////////////////////
// Return the total number of pages in the document.
DV.controller.numberOfPages = function() {
return this.models.document.totalPages;
};
// Change the documents' sections, re-rendering the navigation. "sections"
// should be an array of sections in the canonical format:
// {title: "Chapter 1", pages: "1-12"}
DV.controller.setSections = function(sections) {
DV.Schema.data.sections = sections;
this.models.chapters.loadChapters();
this.helpers.renderNavigation();
};
// Get a list of every section in the document.
DV.controller.getSections = function() {
return _.clone(DV.Schema.data.sections || []);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment