diff --git a/Mac/MainWindow/Detail/main_mac.js b/Mac/MainWindow/Detail/main_mac.js new file mode 100644 index 000000000..a5b679642 --- /dev/null +++ b/Mac/MainWindow/Detail/main_mac.js @@ -0,0 +1,19 @@ +// These mouse functions are used by NetNewsWire for Mac to display link previews +function mouseDidEnterLink(anchor) { + window.webkit.messageHandlers.mouseDidEnter.postMessage(anchor.href); +} +function mouseDidExitLink(anchor) { + window.webkit.messageHandlers.mouseDidExit.postMessage(anchor.href); +} + +// Add the mouse listeners for the above functions +function linkHover() { + document.querySelectorAll("a").forEach(element => { + element.addEventListener("mouseenter", function() { mouseDidEnterLink(this) }); + element.addEventListener("mouseleave", function() { mouseDidExitLink(this) }); + }); +} + +function postRenderProcessing() { + linkHover() +} diff --git a/Mac/MainWindow/Detail/page.html b/Mac/MainWindow/Detail/page.html index 7482a74b0..b9cac098b 100644 --- a/Mac/MainWindow/Detail/page.html +++ b/Mac/MainWindow/Detail/page.html @@ -3,6 +3,7 @@ + diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 6c7005aa9..101191734 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -58,6 +58,8 @@ 513C5D0F232574E4003D4054 /* SyncDatabase.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 51554C01228B6EB50055115A /* SyncDatabase.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 5142192A23522B5500E07E2C /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5142192923522B5500E07E2C /* ImageViewController.swift */; }; 514219372352510100E07E2C /* ImageScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 514219362352510100E07E2C /* ImageScrollView.swift */; }; + 5142194B2353C1CF00E07E2C /* main_mac.js in Resources */ = {isa = PBXBuildFile; fileRef = 5142194A2353C1CF00E07E2C /* main_mac.js */; }; + 514219582353C28900E07E2C /* main_ios.js in Resources */ = {isa = PBXBuildFile; fileRef = 514219572353C28900E07E2C /* main_ios.js */; }; 5144EA2F2279FAB600D19003 /* AccountsDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5144EA2E2279FAB600D19003 /* AccountsDetailViewController.swift */; }; 5144EA362279FC3D00D19003 /* AccountsAddLocal.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5144EA352279FC3D00D19003 /* AccountsAddLocal.xib */; }; 5144EA382279FC6200D19003 /* AccountsAddLocalWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5144EA372279FC6200D19003 /* AccountsAddLocalWindowController.swift */; }; @@ -754,6 +756,8 @@ 513C5CED232571C2003D4054 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 5142192923522B5500E07E2C /* ImageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewController.swift; sourceTree = ""; }; 514219362352510100E07E2C /* ImageScrollView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageScrollView.swift; sourceTree = ""; }; + 5142194A2353C1CF00E07E2C /* main_mac.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = main_mac.js; sourceTree = ""; }; + 514219572353C28900E07E2C /* main_ios.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = main_ios.js; sourceTree = ""; }; 5144EA2E2279FAB600D19003 /* AccountsDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountsDetailViewController.swift; sourceTree = ""; }; 5144EA352279FC3D00D19003 /* AccountsAddLocal.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AccountsAddLocal.xib; sourceTree = ""; }; 5144EA372279FC6200D19003 /* AccountsAddLocalWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsAddLocalWindowController.swift; sourceTree = ""; }; @@ -1684,6 +1688,7 @@ 84E8E0EA202F693600562D8F /* DetailWebView.swift */, 84D52E941FE588BB00D14F5B /* DetailStatusBarView.swift */, B528F81D23333C7E00E735DD /* page.html */, + 5142194A2353C1CF00E07E2C /* main_mac.js */, 848362FC2262A30800DA1D35 /* styleSheet.css */, 5127B235222B4849006D641D /* Keyboard */, ); @@ -1980,8 +1985,9 @@ 51F85BEC227251DF00C787DC /* Acknowledgments.rtf */, 51F85BEE2272520B00C787DC /* Thanks.rtf */, 51F85BF22272531500C787DC /* Dedication.rtf */, - 51C452B72265178500C03939 /* styleSheet.css */, 51BB7C302335ACDE008E8144 /* page.html */, + 514219572353C28900E07E2C /* main_ios.js */, + 51C452B72265178500C03939 /* styleSheet.css */, 84C9FC9B2262A1A900D921D6 /* Assets.xcassets */, 84C9FC9C2262A1A900D921D6 /* Info.plist */, 84BB0F812333426400DED65E /* NetNewsWire.entitlements */, @@ -2555,6 +2561,7 @@ 49F40DF92335B71000552BF4 /* newsfoot.js in Resources */, 51F85BEF2272520B00C787DC /* Thanks.rtf in Resources */, 84C9FC9D2262A1A900D921D6 /* Assets.xcassets in Resources */, + 514219582353C28900E07E2C /* main_ios.js in Resources */, 51C452B82265178500C03939 /* styleSheet.css in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2574,6 +2581,7 @@ 84C9FC7D22629E1200D921D6 /* AccountsDetail.xib in Resources */, 517630042336215100E15FFF /* main.js in Resources */, 5144EA362279FC3D00D19003 /* AccountsAddLocal.xib in Resources */, + 5142194B2353C1CF00E07E2C /* main_mac.js in Resources */, 84C9FC8C22629E8F00D921D6 /* KeyboardShortcuts.html in Resources */, 5144EA3B227A379E00D19003 /* ImportOPMLSheet.xib in Resources */, 844B5B691FEA20DF00C7C76A /* SidebarKeyboardShortcuts.plist in Resources */, diff --git a/Shared/Article Rendering/main.js b/Shared/Article Rendering/main.js index 98147e77a..ea399c175 100644 --- a/Shared/Article Rendering/main.js +++ b/Shared/Article Rendering/main.js @@ -1,31 +1,3 @@ -// These mouse functions are used by NetNewsWire for Mac to display link previews -function mouseDidEnterLink(anchor) { - window.webkit.messageHandlers.mouseDidEnter.postMessage(anchor.href); -} -function mouseDidExitLink(anchor) { - window.webkit.messageHandlers.mouseDidExit.postMessage(anchor.href); -} - -// Add the mouse listeners for the above functions -function linkHover() { - document.querySelectorAll("a").forEach(element => { - element.addEventListener("mouseenter", function() { mouseDidEnterLink(this) }); - element.addEventListener("mouseleave", function() { mouseDidExitLink(this) }); - }); -} - -// 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) }); - }); -} - // Here we are making iframes responsive. Particularly useful for inline Youtube videos. function wrapFrames() { document.querySelectorAll("iframe").forEach(element => { @@ -42,15 +14,6 @@ function stripStyles() { document.getElementsByTagName("body")[0].querySelectorAll("[style]").forEach(element => element.removeAttribute("style")); } -// 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 error() { document.body.innerHTML = "error"; } @@ -63,7 +26,5 @@ function render(data) { wrapFrames() stripStyles() - linkHover() - imageClicks() - inlineVideos() + postRenderProcessing() } diff --git a/iOS/Resources/main_ios.js b/iOS/Resources/main_ios.js new file mode 100644 index 000000000..28b49d5e2 --- /dev/null +++ b/iOS/Resources/main_ios.js @@ -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() +} diff --git a/iOS/Resources/page.html b/iOS/Resources/page.html index 101daec87..9d60b7f68 100644 --- a/iOS/Resources/page.html +++ b/iOS/Resources/page.html @@ -7,6 +7,7 @@ } +