Split Mac and iOS specific javascript into individual files.

This commit is contained in:
Maurice Parker
2019-10-13 15:47:11 -05:00
parent bb31c913e4
commit a1f26898c8
6 changed files with 56 additions and 41 deletions

25
iOS/Resources/main_ios.js Normal file
View File

@@ -0,0 +1,25 @@
// Used to pop a resizable image view
function imageWasClicked(img) {
window.webkit.messageHandlers.imageWasClicked.postMessage(img.src);
}
// Add the click listeners for images
function imageClicks() {
document.querySelectorAll("img").forEach(element => {
element.addEventListener("click", function() { imageWasClicked(this) });
});
}
// Add the playsinline attribute to any HTML5 videos that don't have it.
// Without this attribute videos may autoplay and take over the whole screen
// on an iphone when viewing an article.
function inlineVideos() {
document.querySelectorAll("video").forEach(element => {
element.setAttribute("playsinline", true)
});
}
function postRenderProcessing() {
imageClicks()
inlineVideos()
}

View File

@@ -7,6 +7,7 @@
}
</style>
<script src="main.js"></script>
<script src="main_ios.js"></script>
<script src="newsfoot.js" async="async"></script>
</head>
<body>