mirror of
https://github.com/ivabus/www
synced 2024-11-30 00:55:06 +03:00
Merge pull request #136 from teaxyz/bugfix/whitepaper-adobe-preview
fix: language selection on whitepaper page
This commit is contained in:
commit
e02c835563
1 changed files with 61 additions and 31 deletions
|
@ -42,21 +42,6 @@
|
||||||
<div id="adobe-dc-view" style="width: 100%;"></div>
|
<div id="adobe-dc-view" style="width: 100%;"></div>
|
||||||
<script src="https://documentservices.adobe.com/view-sdk/viewer.js"></script>
|
<script src="https://documentservices.adobe.com/view-sdk/viewer.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
document.addEventListener("adobe_dc_view_sdk.ready", function(){
|
|
||||||
//Must change clientId before final merge
|
|
||||||
var adobeDCView = new AdobeDC.View({clientId: "fc933927b4e947c2aaf9a7b33b26f0b4", divId: "adobe-dc-view"});
|
|
||||||
adobeDCView.previewFile({
|
|
||||||
content:{location: {url: "https://tea.xyz/tea.white-paper.pdf"}},
|
|
||||||
metaData:{fileName: "tea.white-paper.pdf"}
|
|
||||||
}, {embedMode: "IN_LINE"});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
const versions = [
|
const versions = [
|
||||||
['English', ''],
|
['English', ''],
|
||||||
['Bahasa Indonesia', '_id'],
|
['Bahasa Indonesia', '_id'],
|
||||||
|
@ -68,19 +53,64 @@
|
||||||
['官话', '_zh']
|
['官话', '_zh']
|
||||||
];
|
];
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
let adobeDcView;
|
||||||
for (const lang of versions) {
|
|
||||||
|
|
||||||
$('#language-selector').append("<li><a class=\"dropdown-item\" onclick=\"go(\'" + lang[1] + "')\">" + lang[0] + "</a></li>");
|
const getAdobeDcView = () => {
|
||||||
|
if (!adobeDcView) {
|
||||||
|
adobeDCView = new AdobeDC.View({
|
||||||
|
clientId: "fc933927b4e947c2aaf9a7b33b26f0b4",
|
||||||
|
divId: "adobe-dc-view"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return adobeDCView;
|
||||||
}
|
}
|
||||||
}, false);
|
|
||||||
|
|
||||||
function go(suffix) {
|
const getWhitePaperUrl = (suffix = '') => {
|
||||||
const url = 'https://tea.xyz/tea.white-paper' + suffix + '.pdf';
|
return 'https://tea.xyz/tea.white-paper' + suffix + '.pdf';
|
||||||
document.getElementById('wp-iframe').setAttribute('src', url + '#toolbar=0&navpanes=0&view=fitH');
|
}
|
||||||
document.getElementById('mobile-wp-download').setAttribute('href', url);
|
|
||||||
|
document.addEventListener("adobe_dc_view_sdk.ready", function(){
|
||||||
|
//Must change clientId before final merge
|
||||||
|
try {
|
||||||
|
for (const lang of versions) {
|
||||||
|
$('#language-selector').append("<li><a class=\"dropdown-item\" onclick=\"viewWhitepaper(\'" + lang[1] + "')\">" + lang[0] + "</a></li>");
|
||||||
|
}
|
||||||
|
const adobeDCView = getAdobeDcView();
|
||||||
|
|
||||||
|
adobeDCView.previewFile({
|
||||||
|
content:{
|
||||||
|
location: {
|
||||||
|
url: getWhitePaperUrl(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
metaData:{
|
||||||
|
fileName: "tea.white-paper.pdf"
|
||||||
|
}
|
||||||
|
}, { embedMode: "IN_LINE" });
|
||||||
|
} catch (error) {
|
||||||
|
console.error('test:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function viewWhitepaper(suffix) {
|
||||||
|
const adobeDCView = getAdobeDcView();
|
||||||
|
const url = getWhitePaperUrl(suffix);
|
||||||
|
adobeDCView.previewFile({
|
||||||
|
content:{
|
||||||
|
location: { url }
|
||||||
|
},
|
||||||
|
metaData:{
|
||||||
|
fileName: "tea.white-paper.pdf"
|
||||||
|
}
|
||||||
|
}, { embedMode: "IN_LINE" });
|
||||||
|
// document.getElementById('mobile-wp-download').setAttribute('href', url);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<!-- Start PDF
|
<!-- Start PDF
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue