Skip to content

Commit c168bb9

Browse files
committed
feat: add allowPopups option
1 parent f6fece4 commit c168bb9

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/managers/continuous/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class ContinuousViewManager extends DefaultViewManager {
2222
height: undefined,
2323
snap: false,
2424
afterScrolledTimeout: 10,
25-
allowScriptedContent: false
25+
allowScriptedContent: false,
26+
allowPopups: false
2627
});
2728

2829
extend(this.settings, options.settings || {});
@@ -40,7 +41,8 @@ class ContinuousViewManager extends DefaultViewManager {
4041
width: 0,
4142
height: 0,
4243
forceEvenPages: false,
43-
allowScriptedContent: this.settings.allowScriptedContent
44+
allowScriptedContent: this.settings.allowScriptedContent,
45+
allowPopups: this.settings.allowPopups
4446
};
4547

4648
this.scrollTop = 0;
@@ -382,7 +384,7 @@ class ContinuousViewManager extends DefaultViewManager {
382384
} else {
383385
if(this.settings.direction === 'rtl') {
384386
if (!this.settings.fullsize) {
385-
this.scrollTo(prevLeft, 0, true);
387+
this.scrollTo(prevLeft, 0, true);
386388
} else {
387389
this.scrollTo(prevLeft + Math.floor(bounds.width), 0, true);
388390
}

src/managers/default/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class DefaultViewManager {
2727
flow: "scrolled",
2828
ignoreClass: "",
2929
fullsize: undefined,
30-
allowScriptedContent: false
30+
allowScriptedContent: false,
31+
allowPopups: false
3132
});
3233

3334
extend(this.settings, options.settings || {});
@@ -41,7 +42,8 @@ class DefaultViewManager {
4142
width: 0,
4243
height: 0,
4344
forceEvenPages: true,
44-
allowScriptedContent: this.settings.allowScriptedContent
45+
allowScriptedContent: this.settings.allowScriptedContent,
46+
allowPopups: this.settings.allowPopups
4547
};
4648

4749
this.rendered = false;
@@ -356,11 +358,11 @@ class DefaultViewManager {
356358
}
357359
if(this.settings.direction === 'rtl'){
358360
/***
359-
the `floor` function above (L343) is on positive values, so we should add one `layout.delta`
361+
the `floor` function above (L343) is on positive values, so we should add one `layout.delta`
360362
to distX or use `Math.ceil` function, or multiply offset.left by -1
361363
before `Math.floor`
362364
*/
363-
distX = distX + this.layout.delta
365+
distX = distX + this.layout.delta
364366
distX = distX - width
365367
}
366368
this.scrollTo(distX, distY, true);
@@ -672,8 +674,8 @@ class DefaultViewManager {
672674
let pageHeight = (container.height < window.innerHeight) ? container.height : window.innerHeight;
673675
let pageWidth = (container.width < window.innerWidth) ? container.width : window.innerWidth;
674676
let vertical = (this.settings.axis === "vertical");
675-
let rtl = (this.settings.direction === "rtl");
676-
677+
let rtl = (this.settings.direction === "rtl");
678+
677679
let offset = 0;
678680
let used = 0;
679681

src/managers/views/iframe.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class IframeView {
1717
globalLayoutProperties: {},
1818
method: undefined,
1919
forceRight: false,
20-
allowScriptedContent: false
20+
allowScriptedContent: false,
21+
allowPopups: false
2122
}, options || {});
2223

2324
this.id = "epubjs-view-" + uuid();
@@ -92,9 +93,12 @@ class IframeView {
9293
// sandbox
9394
this.iframe.sandbox = "allow-same-origin";
9495
if (this.settings.allowScriptedContent) {
95-
this.iframe.sandbox += " allow-scripts"
96+
this.iframe.sandbox += " allow-scripts";
9697
}
97-
98+
if (this.settings.allowPopups) {
99+
this.iframe.sandbox += " allow-popups";
100+
}
101+
98102
this.iframe.setAttribute("enable-annotation", "true");
99103

100104
this.resizing = true;
@@ -228,7 +232,7 @@ class IframeView {
228232
this.lock("both", width, height);
229233
} else if(this.settings.axis === "horizontal") {
230234
this.lock("height", width, height);
231-
} else {
235+
} else {
232236
this.lock("width", width, height);
233237
}
234238

src/rendition.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import ContinuousViewManager from "./managers/continuous/index";
3838
* @param {boolean | object} [options.snap=false] use snap scrolling
3939
* @param {string} [options.defaultDirection='ltr'] default text direction
4040
* @param {boolean} [options.allowScriptedContent=false] enable running scripts in content
41+
* @param {boolean} [options.allowPopups=false] enable opening popup in content
4142
*/
4243
class Rendition {
4344
constructor(book, options) {
@@ -57,7 +58,8 @@ class Rendition {
5758
script: null,
5859
snap: false,
5960
defaultDirection: "ltr",
60-
allowScriptedContent: false
61+
allowScriptedContent: false,
62+
allowPopups: false
6163
});
6264

6365
extend(this.settings, options);

0 commit comments

Comments
 (0)