Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test epub #1284

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
55 changes: 42 additions & 13 deletions src/section.js
Expand Up @@ -51,26 +51,55 @@ class Section {
var request = _request || this.request || Request;
var loading = new defer();
var loaded = loading.promise;
if (this.contents) {
loading.resolve(this.contents);
} else {
//KEM: this is where the file is loaded and turned into xml
//KEM: add in a load to the smil file and append it?
request(this.url)
.then(function (xml) {
// var directory = new Url(this.url).directory;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main change in section is that instead of loading just the page url, I also load the smil file first and then feed the result into where it loads the main page, in order to append it onto the iframe html.

//KEM: this is where the file is loaded and turned into xml
//KEM: add in a load to the smil file and append it?

//KEM: try to load overlay
if (this.overlay) {
if (this.contents) {
loading.resolve(this.contents);
} else {
request(this.overlay.url).then(function (overlayXml) {
var div = document.createElement("div");
//overlay is returning as a string? possibly because xml instead of xhtml
var start = overlayXml.search("<smil");
var xmlStr = overlayXml.substring(start);
div.insertAdjacentHTML('beforeend', xmlStr);
this.mediaOverlay = div;
return request(this.url).then(function (xml) {
this.document = xml;
this.contents = xml.documentElement;
this.contents.appendChild(div);
return this.hooks.content.trigger(this.document, this);

}.bind(this)).then(function () {
loading.resolve(this.contents);
}.bind(this)).catch(function (error) {
loading.reject(error);
});
}
.bind(this)).catch(function (error) {
loading.reject(error);
});
}
}
else {
if (this.contents) {
loading.resolve(this.contents);
} else {
request(this.url).then(function (xml) {
// var directory = new Url(this.url).directory;
this.document = xml;
this.contents = xml.documentElement;

return this.hooks.content.trigger(this.document, this);
}.bind(this))
.then(function () {

}.bind(this)).then(function () {
loading.resolve(this.contents);
}.bind(this))
.catch(function (error) {
}.bind(this)).catch(function (error) {
loading.reject(error);
});
}
}

return loaded;
Expand Down