1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-04 15:09:16 +02:00

Update CFI marker to use textContent, pageListReady only calls when a pagelist is present

This commit is contained in:
Fred Chasen 2014-02-28 19:42:39 -08:00
parent fc50b6ed51
commit aba8dc3c6f
14 changed files with 44 additions and 29 deletions

2
books

@ -1 +1 @@
Subproject commit 950c742b3d66cc7ac53bd0663a41315f001da1c4 Subproject commit ab9755a74714b647290c861f666515de220935d8

View file

@ -2036,7 +2036,6 @@ EPUBJS.Book.prototype.unpack = function(packageXml){
// No pageList found // No pageList found
if(pageList.length === 0) { if(pageList.length === 0) {
book.ready.pageList.resolve([]);
return; return;
} }
@ -2163,16 +2162,16 @@ EPUBJS.Book.prototype.generatePageList = function(width, height){
// Width and Height are optional and will default to the current dimensions // Width and Height are optional and will default to the current dimensions
EPUBJS.Book.prototype.generatePagination = function(width, height) { EPUBJS.Book.prototype.generatePagination = function(width, height) {
var book = this; var book = this;
var pageListReady;
this.ready.spine.promise.then(function(){ this.ready.spine.promise.then(function(){
pageListReady = book.generatePageList(width, height).then(function(pageList){ book.generatePageList(width, height).then(function(pageList){
book.pageList = book.contents.pageList = pageList; book.pageList = book.contents.pageList = pageList;
book.pagination.process(pageList); book.pagination.process(pageList);
book.ready.pageList.resolve(book.pageList); book.ready.pageList.resolve(book.pageList);
}); });
}); });
return pageListReady;
return this.pageListReady;
}; };
// Process the pagination from a JSON array containing the pagelist // Process the pagination from a JSON array containing the pagelist
@ -3613,7 +3612,7 @@ EPUBJS.EpubCFI.prototype.removeMarker = function(marker, _doc) {
nextSib.nodeType === 3 && nextSib.nodeType === 3 &&
prevSib.nodeType === 3){ prevSib.nodeType === 3){
prevSib.innerText += nextSib.innerText; prevSib.textContent += nextSib.textContent;
marker.parentElement.removeChild(nextSib); marker.parentElement.removeChild(nextSib);
} }
marker.parentElement.removeChild(marker); marker.parentElement.removeChild(marker);

6
build/epub.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -2035,7 +2035,6 @@ EPUBJS.Book.prototype.unpack = function(packageXml){
// No pageList found // No pageList found
if(pageList.length === 0) { if(pageList.length === 0) {
book.ready.pageList.resolve([]);
return; return;
} }
@ -2162,16 +2161,16 @@ EPUBJS.Book.prototype.generatePageList = function(width, height){
// Width and Height are optional and will default to the current dimensions // Width and Height are optional and will default to the current dimensions
EPUBJS.Book.prototype.generatePagination = function(width, height) { EPUBJS.Book.prototype.generatePagination = function(width, height) {
var book = this; var book = this;
var pageListReady;
this.ready.spine.promise.then(function(){ this.ready.spine.promise.then(function(){
pageListReady = book.generatePageList(width, height).then(function(pageList){ book.generatePageList(width, height).then(function(pageList){
book.pageList = book.contents.pageList = pageList; book.pageList = book.contents.pageList = pageList;
book.pagination.process(pageList); book.pagination.process(pageList);
book.ready.pageList.resolve(book.pageList); book.ready.pageList.resolve(book.pageList);
}); });
}); });
return pageListReady;
return this.pageListReady;
}; };
// Process the pagination from a JSON array containing the pagelist // Process the pagination from a JSON array containing the pagelist
@ -3612,7 +3611,7 @@ EPUBJS.EpubCFI.prototype.removeMarker = function(marker, _doc) {
nextSib.nodeType === 3 && nextSib.nodeType === 3 &&
prevSib.nodeType === 3){ prevSib.nodeType === 3){
prevSib.innerText += nextSib.innerText; prevSib.textContent += nextSib.textContent;
marker.parentElement.removeChild(nextSib); marker.parentElement.removeChild(nextSib);
} }
marker.parentElement.removeChild(marker); marker.parentElement.removeChild(marker);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -249,8 +249,17 @@ EPUBJS.Reader.prototype.hashChanged = function(){
}; };
EPUBJS.Reader.prototype.selectedRange = function(range){ EPUBJS.Reader.prototype.selectedRange = function(range){
var epubcfi = new EPUBJS.EpubCFI();
var cfi = epubcfi.generateCfiFromElement(range.anchorNode.parentElement, this.book.renderer.currentChapter.cfiBase);
var cfiFragment = "#"+cfi;
console.log("range", range) console.log("range", range)
}; console.log("anchor", cfi)
// Update the History Location
if(this.settings.history &&
window.location.hash != cfiFragment) {
// Add CFI fragment to the history
history.pushState({}, '', cfiFragment);
}};
//-- Enable binding events to reader //-- Enable binding events to reader
RSVP.EventTarget.mixin(EPUBJS.Reader.prototype); RSVP.EventTarget.mixin(EPUBJS.Reader.prototype);

6
demo/js/epub.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -249,8 +249,17 @@ EPUBJS.Reader.prototype.hashChanged = function(){
}; };
EPUBJS.Reader.prototype.selectedRange = function(range){ EPUBJS.Reader.prototype.selectedRange = function(range){
var epubcfi = new EPUBJS.EpubCFI();
var cfi = epubcfi.generateCfiFromElement(range.anchorNode.parentElement, this.book.renderer.currentChapter.cfiBase);
var cfiFragment = "#"+cfi;
console.log("range", range) console.log("range", range)
}; console.log("anchor", cfi)
// Update the History Location
if(this.settings.history &&
window.location.hash != cfiFragment) {
// Add CFI fragment to the history
history.pushState({}, '', cfiFragment);
}};
//-- Enable binding events to reader //-- Enable binding events to reader
RSVP.EventTarget.mixin(EPUBJS.Reader.prototype); RSVP.EventTarget.mixin(EPUBJS.Reader.prototype);

View file

@ -260,7 +260,6 @@ EPUBJS.Book.prototype.unpack = function(packageXml){
// No pageList found // No pageList found
if(pageList.length === 0) { if(pageList.length === 0) {
book.ready.pageList.resolve([]);
return; return;
} }
@ -387,16 +386,16 @@ EPUBJS.Book.prototype.generatePageList = function(width, height){
// Width and Height are optional and will default to the current dimensions // Width and Height are optional and will default to the current dimensions
EPUBJS.Book.prototype.generatePagination = function(width, height) { EPUBJS.Book.prototype.generatePagination = function(width, height) {
var book = this; var book = this;
var pageListReady;
this.ready.spine.promise.then(function(){ this.ready.spine.promise.then(function(){
pageListReady = book.generatePageList(width, height).then(function(pageList){ book.generatePageList(width, height).then(function(pageList){
book.pageList = book.contents.pageList = pageList; book.pageList = book.contents.pageList = pageList;
book.pagination.process(pageList); book.pagination.process(pageList);
book.ready.pageList.resolve(book.pageList); book.ready.pageList.resolve(book.pageList);
}); });
}); });
return pageListReady;
return this.pageListReady;
}; };
// Process the pagination from a JSON array containing the pagelist // Process the pagination from a JSON array containing the pagelist

View file

@ -242,7 +242,7 @@ EPUBJS.EpubCFI.prototype.removeMarker = function(marker, _doc) {
nextSib.nodeType === 3 && nextSib.nodeType === 3 &&
prevSib.nodeType === 3){ prevSib.nodeType === 3){
prevSib.innerText += nextSib.innerText; prevSib.textContent += nextSib.textContent;
marker.parentElement.removeChild(nextSib); marker.parentElement.removeChild(nextSib);
} }
marker.parentElement.removeChild(marker); marker.parentElement.removeChild(marker);