diff options
Diffstat (limited to 'lib/epub.js/src/managers')
-rw-r--r-- | lib/epub.js/src/managers/continuous/index.js | 10 | ||||
-rw-r--r-- | lib/epub.js/src/managers/default/index.js | 16 | ||||
-rw-r--r-- | lib/epub.js/src/managers/views/iframe.js | 20 |
3 files changed, 35 insertions, 11 deletions
diff --git a/lib/epub.js/src/managers/continuous/index.js b/lib/epub.js/src/managers/continuous/index.js index e6a9e61..d61f8f7 100644 --- a/lib/epub.js/src/managers/continuous/index.js +++ b/lib/epub.js/src/managers/continuous/index.js @@ -21,7 +21,9 @@ class ContinuousViewManager extends DefaultViewManager { width: undefined, height: undefined, snap: false, - afterScrolledTimeout: 10 + afterScrolledTimeout: 10, + allowScriptedContent: false, + allowPopups: false }); extend(this.settings, options.settings || {}); @@ -38,7 +40,9 @@ class ContinuousViewManager extends DefaultViewManager { layout: this.layout, width: 0, height: 0, - forceEvenPages: false + forceEvenPages: false, + allowScriptedContent: this.settings.allowScriptedContent, + allowPopups: this.settings.allowPopups }; this.scrollTop = 0; @@ -380,7 +384,7 @@ class ContinuousViewManager extends DefaultViewManager { } else { if(this.settings.direction === 'rtl') { if (!this.settings.fullsize) { - this.scrollTo(prevLeft, 0, true); + this.scrollTo(prevLeft, 0, true); } else { this.scrollTo(prevLeft + Math.floor(bounds.width), 0, true); } diff --git a/lib/epub.js/src/managers/default/index.js b/lib/epub.js/src/managers/default/index.js index b24a4f6..2812d87 100644 --- a/lib/epub.js/src/managers/default/index.js +++ b/lib/epub.js/src/managers/default/index.js @@ -26,7 +26,9 @@ class DefaultViewManager { writingMode: undefined, flow: "scrolled", ignoreClass: "", - fullsize: undefined + fullsize: undefined, + allowScriptedContent: false, + allowPopups: false }); extend(this.settings, options.settings || {}); @@ -39,7 +41,9 @@ class DefaultViewManager { method: this.settings.method, // srcdoc, blobUrl, write width: 0, height: 0, - forceEvenPages: true + forceEvenPages: true, + allowScriptedContent: this.settings.allowScriptedContent, + allowPopups: this.settings.allowPopups }; this.rendered = false; @@ -354,11 +358,11 @@ class DefaultViewManager { } if(this.settings.direction === 'rtl'){ /*** - the `floor` function above (L343) is on positive values, so we should add one `layout.delta` + the `floor` function above (L343) is on positive values, so we should add one `layout.delta` to distX or use `Math.ceil` function, or multiply offset.left by -1 before `Math.floor` */ - distX = distX + this.layout.delta + distX = distX + this.layout.delta distX = distX - width } this.scrollTo(distX, distY, true); @@ -670,8 +674,8 @@ class DefaultViewManager { let pageHeight = (container.height < window.innerHeight) ? container.height : window.innerHeight; let pageWidth = (container.width < window.innerWidth) ? container.width : window.innerWidth; let vertical = (this.settings.axis === "vertical"); - let rtl = (this.settings.direction === "rtl"); - + let rtl = (this.settings.direction === "rtl"); + let offset = 0; let used = 0; diff --git a/lib/epub.js/src/managers/views/iframe.js b/lib/epub.js/src/managers/views/iframe.js index 76b2c1d..e20e54d 100644 --- a/lib/epub.js/src/managers/views/iframe.js +++ b/lib/epub.js/src/managers/views/iframe.js @@ -16,7 +16,9 @@ class IframeView { layout: undefined, globalLayoutProperties: {}, method: undefined, - forceRight: false + forceRight: false, + allowScriptedContent: false, + allowPopups: false }, options || {}); this.id = "epubjs-view-" + uuid(); @@ -88,6 +90,15 @@ class IframeView { // Back up if seamless isn't supported this.iframe.style.border = "none"; + // sandbox + this.iframe.sandbox = "allow-same-origin"; + if (this.settings.allowScriptedContent) { + this.iframe.sandbox += " allow-scripts"; + } + if (this.settings.allowPopups) { + this.iframe.sandbox += " allow-popups"; + } + this.iframe.setAttribute("enable-annotation", "true"); this.resizing = true; @@ -221,7 +232,7 @@ class IframeView { this.lock("both", width, height); } else if(this.settings.axis === "horizontal") { this.lock("height", width, height); - } else { + } else { this.lock("width", width, height); } @@ -816,6 +827,11 @@ class IframeView { this.stopExpanding = true; this.element.removeChild(this.iframe); + if (this.pane) { + this.pane.element.remove(); + this.pane = undefined; + } + this.iframe = undefined; this.contents = undefined; |