Skip to content

Commit

Permalink
Add EPUB metadata and HTML title info in the location notification
Browse files Browse the repository at this point in the history
  • Loading branch information
MurakamiShinyu committed Jan 30, 2019
1 parent 3b3ba29 commit 4717e21
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/adapt/epub.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ adapt.epub.OPFItem = function() {
/** @type {?string} */ this.id = null;
/** @type {string} */ this.src = "";
/** @type {?string} */ this.mediaType = null;
/** @type {?string} */ this.title = null;
/** @type {Element} */ this.itemRefElement = null;
/** @type {number} */ this.spineIndex = -1;
/** @type {number} */ this.compressedSize = 0;
Expand Down Expand Up @@ -2112,6 +2113,7 @@ adapt.epub.OPFView.prototype.getPageViewItem = function(spineIndex) {
const item = self.opf.spine[spineIndex];
const store = self.opf.store;
store.load(item.src).then(xmldoc => {
item.title = xmldoc.document.title;
const style = store.getStyleForDoc(xmldoc);
const customRenderer = self.makeCustomRenderer(xmldoc);
let viewport = self.viewport;
Expand Down
8 changes: 5 additions & 3 deletions src/adapt/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,9 @@ adapt.viewer.Viewer.prototype.resize = function() {
"t": "nav",
"epageCount": epageCount,
"first": self.currentPage.isFirstPage,
"last": self.currentPage.isLastPage
"last": self.currentPage.isLastPage,
"metadata": self.opf.metadata,
"itemTitle": self.opf.spine[self.pagePosition.spineIndex].title
};
if (self.currentPage.isFirstPage || self.pagePosition.pageIndex == 0 &&
self.opf.spine[self.pagePosition.spineIndex].epage) {
Expand Down Expand Up @@ -908,8 +910,8 @@ adapt.viewer.Viewer.prototype.resize = function() {
*/
adapt.viewer.Viewer.prototype.sendLocationNotification = function(page, cfi) {
/** @type {!adapt.task.Frame.<boolean>} */ const frame = adapt.task.newFrame("sendLocationNotification");
const notification = {"t": "nav", "first": page.isFirstPage,
"last": page.isLastPage};
const notification = {"t": "nav", "first": page.isFirstPage, "last": page.isLastPage,
"metadata": this.opf.metadata, "itemTitle": this.opf.spine[page.spineIndex].title};
const self = this;
this.opf.getEPageFromPosition(/** @type {adapt.epub.Position} */(self.pagePosition)).then(epage => {
notification["epage"] = epage;
Expand Down

0 comments on commit 4717e21

Please sign in to comment.