|
@@ -54,12 +54,17 @@ const updateSizeWithMessage = (element, scalesPageToFit) =>
|
54
|
54
|
}
|
55
|
55
|
`;
|
56
|
56
|
|
57
|
|
-const disableZoom = `
|
58
|
|
- var meta = document.createElement("meta");
|
59
|
|
- meta.setAttribute("name", "viewport");
|
60
|
|
- meta.setAttribute("content", "width=device-width, user-scalable=no");
|
61
|
|
- document.getElementsByTagName("head")[0].appendChild(meta);
|
62
|
|
-`;
|
|
57
|
+const setViewportContent = content => {
|
|
58
|
+ if (!content) {
|
|
59
|
+ return '';
|
|
60
|
+ }
|
|
61
|
+ return `
|
|
62
|
+ var meta = document.createElement("meta");
|
|
63
|
+ meta.setAttribute("name", "viewport");
|
|
64
|
+ meta.setAttribute("content", "${content}");
|
|
65
|
+ document.getElementsByTagName("head")[0].appendChild(meta);
|
|
66
|
+ `;
|
|
67
|
+};
|
63
|
68
|
|
64
|
69
|
const detectZoomChanged = `
|
65
|
70
|
var zoomedin = false;
|
|
@@ -87,7 +92,7 @@ const detectZoomChanged = `
|
87
|
92
|
});
|
88
|
93
|
`;
|
89
|
94
|
|
90
|
|
-const getBaseScript = ({ style, zoomDisabled, scalesPageToFit, scrollEnabledWithZoomedin }) =>
|
|
95
|
+const getBaseScript = ({ style, viewportContent, scalesPageToFit, scrollEnabledWithZoomedin }) =>
|
91
|
96
|
`
|
92
|
97
|
;
|
93
|
98
|
if (!document.getElementById("rnahw-wrapper")) {
|
|
@@ -102,8 +107,8 @@ const getBaseScript = ({ style, zoomDisabled, scalesPageToFit, scrollEnabledWith
|
102
|
107
|
window.addEventListener('load', updateSize);
|
103
|
108
|
window.addEventListener('resize', updateSize);
|
104
|
109
|
${domMutationObserveScript}
|
105
|
|
- ${zoomDisabled ? disableZoom : ''}
|
106
|
|
- ${!zoomDisabled && scrollEnabledWithZoomedin ? detectZoomChanged : ''}
|
|
110
|
+ ${setViewportContent(viewportContent)}
|
|
111
|
+ ${scrollEnabledWithZoomedin ? detectZoomChanged : ''}
|
107
|
112
|
updateSize();
|
108
|
113
|
`;
|
109
|
114
|
|
|
@@ -156,11 +161,11 @@ const getScript = ({
|
156
|
161
|
customStyle,
|
157
|
162
|
customScript,
|
158
|
163
|
style,
|
159
|
|
- zoomDisabled,
|
|
164
|
+ viewportContent,
|
160
|
165
|
scalesPageToFit,
|
161
|
166
|
scrollEnabledWithZoomedin
|
162
|
167
|
}) => {
|
163
|
|
- let script = getBaseScript({ style, zoomDisabled, scalesPageToFit, scrollEnabledWithZoomedin });
|
|
168
|
+ let script = getBaseScript({ style, viewportContent, scalesPageToFit, scrollEnabledWithZoomedin });
|
164
|
169
|
script = files && files.length > 0 ? appendFilesToHead({ files, script }) : script;
|
165
|
170
|
script = appendStylesToHead({ style: customStyle, script });
|
166
|
171
|
customScript && (script = customScript + script);
|