├── .gitignore ├── Classes ├── PFWebViewController.bundle │ ├── PFWebViewToolBar.nib │ ├── icon_back.png │ ├── icon_back@2x.png │ ├── icon_back@3x.png │ ├── icon_back_disable.png │ ├── icon_back_disable@2x.png │ ├── icon_back_disable@3x.png │ ├── icon_close.png │ ├── icon_close@2x.png │ ├── icon_close@3x.png │ ├── icon_next.png │ ├── icon_next@2x.png │ ├── icon_next@3x.png │ ├── icon_next_disable.png │ ├── icon_next_disable@2x.png │ ├── icon_next_disable@3x.png │ ├── icon_read.png │ ├── icon_read@2x.png │ ├── icon_read@3x.png │ ├── icon_read_back.png │ ├── icon_read_back@2x.png │ ├── icon_read_back@3x.png │ ├── icon_read_disable.png │ ├── icon_read_disable@2x.png │ ├── icon_read_disable@3x.png │ ├── icon_safari.png │ ├── icon_safari@2x.png │ ├── icon_safari@3x.png │ ├── index.html │ ├── safari-reader-check.js │ └── safari-reader.js ├── PFWebViewController.h ├── PFWebViewController.m ├── PFWebViewNavigationHeader.h ├── PFWebViewNavigationHeader.m ├── PFWebViewToolBar.h ├── PFWebViewToolBar.m └── PFWebViewToolBar.xib ├── LICENSE ├── PFWebViewController.podspec ├── PFWebViewController.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── PFWebViewControllerFramework.xcscheme ├── PFWebViewController ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── PFWebViewControllerFramework ├── Info.plist └── PFWebViewControllerFramework.h ├── README.md └── Screenshots ├── GitHub_1.png ├── GitHub_2.png ├── Loading.png ├── Reader_Mode_1.png └── Reader_Mode_2.png /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | # Created by https://www.gitignore.io/api/objective-c 4 | 5 | ### Objective-C ### 6 | # Xcode 7 | # 8 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 9 | 10 | ## Build generated 11 | build/ 12 | DerivedData/ 13 | 14 | ## Various settings 15 | *.pbxuser 16 | !default.pbxuser 17 | *.mode1v3 18 | !default.mode1v3 19 | *.mode2v3 20 | !default.mode2v3 21 | *.perspectivev3 22 | !default.perspectivev3 23 | xcuserdata/ 24 | 25 | ## Other 26 | *.moved-aside 27 | *.xcuserstate 28 | 29 | ## Obj-C/Swift specific 30 | *.hmap 31 | *.ipa 32 | *.dSYM.zip 33 | *.dSYM 34 | 35 | # CocoaPods 36 | # 37 | # We recommend against adding the Pods directory to your .gitignore. However 38 | # you should judge for yourself, the pros and cons are mentioned at: 39 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 40 | # 41 | # Pods/ 42 | 43 | # Carthage 44 | # 45 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 46 | # Carthage/Checkouts 47 | 48 | Carthage/Build 49 | 50 | # fastlane 51 | # 52 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 53 | # screenshots whenever they are needed. 54 | # For more information about the recommended setup visit: 55 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 56 | 57 | fastlane/report.xml 58 | fastlane/Preview.html 59 | fastlane/screenshots 60 | fastlane/test_output 61 | 62 | # Code Injection 63 | # 64 | # After new code Injection tools there's a generated folder /iOSInjectionProject 65 | # https://github.com/johnno1962/injectionforxcode 66 | 67 | iOSInjectionProject/ 68 | 69 | ### Objective-C Patch ### 70 | *.xcscmblueprint 71 | -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/PFWebViewToolBar.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/PFWebViewToolBar.nib -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_back.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_back@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_back@2x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_back@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_back@3x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_back_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_back_disable.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_back_disable@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_back_disable@2x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_back_disable@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_back_disable@3x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_close.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_close@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_close@2x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_close@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_close@3x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_next.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_next@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_next@2x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_next@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_next@3x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_next_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_next_disable.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_next_disable@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_next_disable@2x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_next_disable@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_next_disable@3x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_read.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_read.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_read@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_read@2x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_read@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_read@3x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_read_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_read_back.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_read_back@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_read_back@2x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_read_back@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_read_back@3x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_read_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_read_disable.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_read_disable@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_read_disable@2x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_read_disable@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_read_disable@3x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_safari.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_safari.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_safari@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_safari@2x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/icon_safari@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Classes/PFWebViewController.bundle/icon_safari@3x.png -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Reader 8 | 9 | 436 | 460 | 461 | 734 | 735 | 891 | 892 | 893 | 894 | 895 | 896 |
897 | 898 |
899 | 900 | 901 | -------------------------------------------------------------------------------- /Classes/PFWebViewController.bundle/safari-reader.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Apple Inc. All rights reserved. 3 | */ 4 | function articleHeight() { 5 | var e = document.getElementById("article").offsetHeight, 6 | t = parseFloat(getComputedStyle(document.getElementById("article")).marginTop); 7 | return e + 2 * t 8 | } 9 | function smoothScroll(e, t, n, i) { 10 | function a(t, n) { 11 | scrollEventIsSmoothScroll = !0, e.scrollTop = n, setTimeout(function() { 12 | scrollEventIsSmoothScroll = !1 13 | }, 0) 14 | } 15 | const o = 1e3 / 60; 16 | var r = e.scrollTop, 17 | s = r + t, 18 | l = 0, 19 | d = articleHeight() - window.innerHeight; 20 | if (l > s && (s = l), s > d && (s = d), r != s) { 21 | var c = Math.abs(s - r); 22 | if (c < Math.abs(t) && (n = n * c / Math.abs(t)), smoothScrollingAnimator) { 23 | var u = smoothScrollingAnimator.animations[0], 24 | m = u.progress, 25 | g = m > .5 ? 1 - m : m, 26 | h = n / (1 - g), 27 | p = -g * h, 28 | f = s - r, 29 | S = (.5 * f * Math.PI * Math.sin(Math.PI * m), Math.sin(Math.PI / 2 * g)), 30 | C = S * S, 31 | x = (r - s * C) / (1 - C); 32 | return abortSmoothScroll(), smoothScrollingAnimator = new AppleAnimator(h, o, i), smoothScrollingAnimation = new AppleAnimation(x, s, a), smoothScrollingAnimator.addAnimation(smoothScrollingAnimation), void smoothScrollingAnimator.start(p) 33 | } 34 | smoothScrollingAnimator = new AppleAnimator(n, o, i), smoothScrollingAnimation = new AppleAnimation(r, s, a), smoothScrollingAnimator.addAnimation(smoothScrollingAnimation), smoothScrollingAnimator.start() 35 | } 36 | } 37 | function abortSmoothScroll() { 38 | smoothScrollingAnimator.stop(AnimationTerminationCondition.Interrupted), smoothScrollingAnimator = null, smoothScrollingAnimation = null 39 | } 40 | function articleScrolled() { 41 | !scrollEventIsSmoothScroll && smoothScrollingAnimator && abortSmoothScroll() 42 | } 43 | function traverseReaderContent(e, t) { 44 | if (e) { 45 | var n = e.offsetTop, 46 | i = document.createTreeWalker(document.getElementById("article"), NodeFilter.SHOW_ELEMENT, { 47 | acceptNode: function(e) { 48 | var t = e.classList; 49 | return t.contains("page-number") || t.contains("float") || t.contains("page") || t.contains("scrollable") || "HR" === e.tagName || 0 === e.offsetHeight || "inline" === getComputedStyle(e).display || n === e.offsetTop ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT 50 | } 51 | }); 52 | return i.currentNode = e, i[t]() 53 | } 54 | } 55 | function nextReaderContentElement(e) { 56 | return traverseReaderContent(e, "nextNode") 57 | } 58 | function previousReaderContentElement(e) { 59 | return traverseReaderContent(e, "previousNode") 60 | } 61 | function articleTitleElement() { 62 | return document.querySelector("#article .page .title") 63 | } 64 | function keyDown(e) { 65 | var t = !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey), 66 | n = !e.metaKey && !e.altKey && !e.ctrlKey && e.shiftKey; 67 | switch (e.keyCode) { 68 | case 8: 69 | break; 70 | case 74: 71 | ContentAwareScrollerJS.scroll(ContentAwareNavigationDirection.Down); 72 | break; 73 | case 75: 74 | ContentAwareScrollerJS.scroll(ContentAwareNavigationDirection.Up) 75 | } 76 | } 77 | function getArticleScrollPosition() { 78 | scrollInfo = {}, scrollInfo.version = 1; 79 | var e = document.getElementsByClassName("page"); 80 | if (!e.length) 81 | return scrollInfo.pageIndex = 0, scrollInfo; 82 | scrollInfo.pageIndex = e.length - 1; 83 | var t, 84 | n = window.scrollY; 85 | for (t = 0; t < e.length; t++) { 86 | var i = e[t]; 87 | if (i.offsetTop + i.offsetHeight >= n) { 88 | scrollInfo.pageIndex = t; 89 | break 90 | } 91 | } 92 | return scrollInfo 93 | } 94 | function restoreInitialArticleScrollPosition() { 95 | var e = document.getElementsByClassName("page"), 96 | t = e[initialScrollPosition.pageIndex]; 97 | t && (document.body.scrollTop = t.offsetTop) 98 | } 99 | function restoreInitialArticleScrollPositionIfPossible() { 100 | if (!didRestoreInitialScrollPosition) { 101 | if (!initialScrollPosition) 102 | return void (didRestoreInitialScrollPosition = !0); 103 | var e = document.getElementsByClassName("page-number").length; 104 | initialScrollPosition.pageIndex >= e || (setTimeout(restoreInitialArticleScrollPosition, DelayBeforeRestoringScrollPositionInMs), didRestoreInitialScrollPosition = !0) 105 | } 106 | } 107 | function makeWideElementsScrollable() { 108 | for (var e = document.querySelectorAll("table, pre"), t = e.length, n = 0; t > n; ++n) { 109 | var i = e[n]; 110 | if (!i.classList.contains("float") && !i.parentElement.classList.contains("scrollable")) { 111 | var a = document.createElement("div"); 112 | i.parentElement.insertBefore(a, i), i.remove(), a.insertBefore(i), a.classList.add("scrollable") 113 | } 114 | } 115 | } 116 | function loadTwitterJavaScript() { 117 | window.twttr = function(e, t, n) { 118 | var i, 119 | a, 120 | o = e.getElementsByTagName(t)[0]; 121 | if (!e.getElementById(n)) 122 | return a = e.createElement(t), a.id = n, a.src = "https://platform.twitter.com/widgets.js", o.parentNode.insertBefore(a, o), window.twttr || (i = { 123 | _e: [], 124 | ready: function(e) { 125 | i._e.push(e) 126 | } 127 | }) 128 | }(document, "script", "twitter-wjs") 129 | } 130 | function richTweetWasCreated(e) { 131 | var t = e.parentNode.querySelector(".simple-tweet"); 132 | t.classList.add("hidden") 133 | } 134 | function replaceSimpleTweetsWithRichTweets() { 135 | if (ReaderJS._isJavaScriptEnabled()) { 136 | var e = document.querySelectorAll("[data-reader-tweet-id]"), 137 | t = e.length; 138 | t && (loadTwitterJavaScript(), twttr.ready(function(n) { 139 | for (var i = 0; t > i; ++i) { 140 | var a = e[i]; 141 | n.widgets.createTweet(a.getAttribute("data-reader-tweet-id"), a, { 142 | dnt: !0 143 | }).then(richTweetWasCreated) 144 | } 145 | })) 146 | } 147 | } 148 | function prepareTweetsInPrintingMailingFrame(e) { 149 | for (var t = e.querySelectorAll(".tweet-wrapper"), n = t.length, i = 0; n > i; ++i) { 150 | var a = t[i], 151 | o = a.querySelector("iframe"); 152 | o && o.remove(); 153 | var r = a.querySelector(".simple-tweet"); 154 | r && r.classList.remove("hidden") 155 | } 156 | } 157 | function localeForElement(e) { 158 | var t = "en" 159 | return "en" && t.length && "und" !== t ? t : "en" 160 | } 161 | function anchorForURL(e) { 162 | var t = document.createElement("a"); 163 | return t.href = e, t 164 | } 165 | function stopExtendingElementBeyondTextColumn(e) { 166 | e.classList.remove("extendsBeyondTextColumn"), e.style.removeProperty("width"), e.style.removeProperty("-webkit-margin-start") 167 | } 168 | function leadingMarginAndPaddingAppliedToElementFromAncestors(e) { 169 | for (var t = 0, n = e.parentElement; n && !n.classList.contains("page");) { 170 | var i = getComputedStyle(n); 171 | t += parseFloat(i["-webkit-padding-start"]) + parseFloat(i["-webkit-margin-start"]), n = n.parentElement 172 | } 173 | return t 174 | } 175 | function extendElementBeyondTextColumn(e, t, n) { 176 | e.classList.add("extendsBeyondTextColumn"), e.style.setProperty("width", t + "px"), e.style.setProperty("-webkit-margin-start", (n - t) / 2 - leadingMarginAndPaddingAppliedToElementFromAncestors(e) + "px") 177 | } 178 | function textSizeIndexIsValid(e) { 179 | return "number" == typeof e && e >= MinTextZoomIndex && MaxTextZoomIndex >= e 180 | } 181 | function monitorMouseDownForPotentialDeactivation(e) { 182 | lastMouseDownWasOutsideOfPaper = e && ReaderAppearanceJS.usesPaperAppearance() && !document.getElementById("article").contains(e.target) 183 | } 184 | function deactivateIfEventIsOutsideOfPaperContainer(e) { 185 | lastMouseDownWasOutsideOfPaper && e && ReaderAppearanceJS.usesPaperAppearance() && !document.getElementById("article").contains(e.target) && (ReaderJS.readerWillEnterBackground()) 186 | } 187 | function updatePageNumbers() { 188 | for (var e = document.getElementsByClassName("page-number"), t = e.length, n = ReaderJS.isLoadingNextPage(), i = 0; t > i; ++i) 189 | n ? e[i].textContent = getLocalizedString("Page %@").format(i + 1) : e[i].textContent = getLocalizedString("Page %@ of %@").format(i + 1, t) 190 | } 191 | function incomingPagePlaceholder() { 192 | return document.getElementById("incoming-page-placeholder") 193 | } 194 | function addIncomingPagePlaceholder(e) { 195 | var t = document.createElement("div"); 196 | t.className = "page", t.id = "incoming-page-placeholder"; 197 | var n = document.createElement("div"); 198 | n.id = "incoming-page-corner"; 199 | var i = document.createElement("div"); 200 | i.id = "incoming-page-text", i.innerText = getLocalizedString(e ? "Loading Next Page\u2026" : "Connect to the Internet to view remaining pages."), n.appendChild(i), t.appendChild(n), document.getElementById("article").appendChild(t) 201 | } 202 | function removeIncomingPagePlaceholder() { 203 | var e = incomingPagePlaceholder(); 204 | e.parentNode.removeChild(e) 205 | } 206 | function nextPageContainer() { 207 | return document.getElementById("next-page-container") 208 | } 209 | function getLocalizedString(e) { 210 | var t = ""; 211 | return t ? t : e 212 | } 213 | function nextPageLoadComplete() { 214 | return null 215 | } 216 | function contentElementTouchingTopOfViewport() { 217 | var e = articleTitleElement(); 218 | do { 219 | var t = e.getBoundingClientRect(); 220 | if (t.top <= 0 && t.bottom >= 0) 221 | return e 222 | } while (e = nextReaderContentElement(e)); 223 | return null 224 | } 225 | var LoadNextPageDelay = 250, 226 | MaxNumberOfNextPagesToLoad = 80, 227 | ReaderOperationMode = { 228 | Normal: 0, 229 | OffscreenFetching: 1, 230 | ArchiveViewing: 2 231 | }, 232 | DelayBeforeRestoringScrollPositionInMs = 1e3; 233 | String.prototype.format = function() { 234 | for (var e = this.split("%@"), t = 0, n = arguments.length; n > t; ++t) 235 | e.splice(2 * t + 1, 0, arguments[t].toString()); 236 | return e.join("") 237 | }; 238 | var AnimationTerminationCondition = { 239 | Interrupted: 0, 240 | CompletedSuccessfully: 1 241 | }; 242 | AppleAnimator = function(e, t, n) { 243 | this.startTime = 0, this.duration = e, this.interval = t, this.animations = [], this.animationFinishedCallback = n, this.currentFrameRequestID = null, this._firstTime = !0; 244 | var i = this; 245 | this.animate = function() { 246 | function e(e, t, n) { 247 | return t > e ? t : e > n ? n : e 248 | } 249 | var t, 250 | n, 251 | a, 252 | o, 253 | n = (new Date).getTime(), 254 | r = i.duration; 255 | t = e(n - i.startTime, 0, r), n = t / r, a = .5 - .5 * Math.cos(Math.PI * n), o = t >= r; 256 | for (var s = i.animations, l = s.length, d = i._firstTime, c = 0; l > c; ++c) 257 | s[c].doFrame(i, a, d, o, n); 258 | return o ? void i.stop(AnimationTerminationCondition.CompletedSuccessfully) : (i._firstTime = !1, void (this.currentFrameRequestID = requestAnimationFrame(i.animate))) 259 | } 260 | }, AppleAnimator.prototype = { 261 | start: function(e) { 262 | var t = (new Date).getTime(), 263 | n = this.interval; 264 | this.startTime = t - n, e && (this.startTime += e), this.currentFrameRequestID = requestAnimationFrame(this.animate) 265 | }, 266 | stop: function(e) { 267 | this.animationFinishedCallback && this.animationFinishedCallback(e), this.currentFrameRequestID && cancelAnimationFrame(this.currentFrameRequestID) 268 | }, 269 | addAnimation: function(e) { 270 | this.animations[this.animations.length] = e 271 | } 272 | }, AppleAnimation = function(e, t, n) { 273 | this.from = e, this.to = t, this.callback = n, this.now = e, this.ease = 0, this.progress = 0 274 | }, AppleAnimation.prototype = { 275 | doFrame: function(e, t, n, i, a) { 276 | var o; 277 | o = i ? this.to : this.from + (this.to - this.from) * t, this.now = o, this.ease = t, this.progress = a, this.callback(e, o, n, i) 278 | } 279 | }; 280 | var scrollEventIsSmoothScroll = !1, 281 | smoothScrollingAnimator, 282 | smoothScrollingAnimation; 283 | window.addEventListener("scroll", articleScrolled, !1); 284 | const ContentAwareNavigationMarker = "reader-content-aware-navigation-marker", 285 | ContentAwareNavigationAnimationDuration = 200, 286 | ContentAwareNavigationElementOffset = 8, 287 | ContentAwareNavigationDirection = { 288 | Up: 0, 289 | Down: 1 290 | }; 291 | ContentAwareScroller = function() { 292 | this._numberOfContentAwareScrollAnimationsInProgress = 0 293 | }, ContentAwareScroller.prototype = { 294 | _contentElementAtTopOfViewport: function() { 295 | var e = articleTitleElement(); 296 | do if (!(e.getBoundingClientRect().top < ContentAwareNavigationElementOffset)) 297 | return e; 298 | while (e = nextReaderContentElement(e)); 299 | return null 300 | }, 301 | _clearTargetOfContentAwareScrolling: function() { 302 | var e = document.getElementById(ContentAwareNavigationMarker); 303 | e && e.removeAttribute("id") 304 | }, 305 | _contentAwareScrollFinished: function(e) { 306 | e === AnimationTerminationCondition.CompletedSuccessfully && (--this._numberOfContentAwareScrollAnimationsInProgress, this._numberOfContentAwareScrollAnimationsInProgress || (smoothScrollingAnimator = null, smoothScrollingAnimation = null, this._clearTargetOfContentAwareScrolling())) 307 | }, 308 | scroll: function(e) { 309 | var t, 310 | n, 311 | i = document.getElementById(ContentAwareNavigationMarker), 312 | a = i || this._contentElementAtTopOfViewport(); 313 | if (e === ContentAwareNavigationDirection.Down) { 314 | var o = Math.abs(a.getBoundingClientRect().top - ContentAwareNavigationElementOffset) < 1; 315 | t = i || o ? nextReaderContentElement(a) : a 316 | } else if (e === ContentAwareNavigationDirection.Up) 317 | if (a === articleTitleElement()) { 318 | if (0 === document.body.scrollTop) 319 | return; 320 | n = -1 * document.body.scrollTop 321 | } else 322 | t = previousReaderContentElement(a); 323 | t && (n = t.getBoundingClientRect().top - ContentAwareNavigationElementOffset), ++this._numberOfContentAwareScrollAnimationsInProgress, smoothScroll(document.body, n, ContentAwareNavigationAnimationDuration, this._contentAwareScrollFinished.bind(this)), this._clearTargetOfContentAwareScrolling(), t && (t.id = ContentAwareNavigationMarker) 324 | } 325 | }, window.addEventListener("keydown", keyDown, !1); 326 | var didRestoreInitialScrollPosition = !1, 327 | initialScrollPosition; 328 | const DefaultFontSizes = [15, 16, 17, 18, 19, 20, 21, 23, 26, 28, 37, 46], 329 | DefaultLineHeights = ["25px", "26px", "27px", "28px", "29px", "30px", "31px", "33px", "37px", "39px", "51px", "62px"], 330 | FontSettings = { 331 | System: { 332 | fontSizes: DefaultFontSizes, 333 | lineHeights: ["25px", "26px", "27px", "29px", "30px", "31px", "32px", "33px", "38px", "39px", "51px", "62px"], 334 | cssClassName: "system" 335 | }, 336 | Athelas: { 337 | fontSizes: DefaultFontSizes, 338 | lineHeights: DefaultLineHeights, 339 | cssClassName: "athelas" 340 | }, 341 | Charter: { 342 | fontSizes: DefaultFontSizes, 343 | lineHeights: ["25px", "26px", "27px", "28px", "29px", "30px", "32px", "34px", "38px", "39px", "51px", "62px"], 344 | cssClassName: "charter" 345 | }, 346 | Georgia: { 347 | fontSizes: DefaultFontSizes, 348 | lineHeights: ["25px", "26px", "27px", "28px", "29px", "30px", "32px", "34px", "38px", "41px", "51px", "62px"], 349 | cssClassName: "georgia" 350 | }, 351 | "Iowan Old Style": { 352 | fontSizes: DefaultFontSizes, 353 | lineHeights: ["25px", "26px", "27px", "28px", "29px", "30px", "32px", "34px", "38px", "39px", "51px", "62px"], 354 | cssClassName: "iowan" 355 | }, 356 | Palatino: { 357 | fontSizes: DefaultFontSizes, 358 | lineHeights: ["25px", "26px", "27px", "28px", "29px", "30px", "31px", "34px", "37px", "40px", "51px", "62px"], 359 | cssClassName: "palatino" 360 | }, 361 | Seravek: { 362 | fontSizes: DefaultFontSizes, 363 | lineHeights: ["25px", "26px", "27px", "28px", "28px", "30px", "31px", "34px", "37px", "39px", "51px", "62px"], 364 | cssClassName: "seravek" 365 | }, 366 | "Times New Roman": { 367 | fontSizes: DefaultFontSizes, 368 | lineHeights: DefaultLineHeights, 369 | cssClassName: "times" 370 | }, 371 | "Hiragino Sans W3": { 372 | fontSizes: DefaultFontSizes, 373 | lineHeights: DefaultLineHeights, 374 | cssClassName: "hiraginosans" 375 | }, 376 | "Hiragino Kaku Gothic ProN": { 377 | fontSizes: DefaultFontSizes, 378 | lineHeights: DefaultLineHeights, 379 | cssClassName: "hiraginokaku" 380 | }, 381 | "Hiragino Mincho ProN": { 382 | fontSizes: DefaultFontSizes, 383 | lineHeights: DefaultLineHeights, 384 | cssClassName: "hiraginomincho" 385 | }, 386 | "Hiragino Maru Gothic ProN": { 387 | fontSizes: DefaultFontSizes, 388 | lineHeights: DefaultLineHeights, 389 | cssClassName: "hiraginomaru" 390 | }, 391 | "PingFang SC": { 392 | fontSizes: DefaultFontSizes, 393 | lineHeights: DefaultLineHeights, 394 | cssClassName: "pingfangsc" 395 | }, 396 | "Heiti SC": { 397 | fontSizes: DefaultFontSizes, 398 | lineHeights: DefaultLineHeights, 399 | cssClassName: "heitisc" 400 | }, 401 | "Songti SC": { 402 | fontSizes: DefaultFontSizes, 403 | lineHeights: DefaultLineHeights, 404 | cssClassName: "songtisc" 405 | }, 406 | "Kaiti SC": { 407 | fontSizes: DefaultFontSizes, 408 | lineHeights: DefaultLineHeights, 409 | cssClassName: "kaitisc" 410 | }, 411 | "Yuanti SC": { 412 | fontSizes: DefaultFontSizes, 413 | lineHeights: DefaultLineHeights, 414 | cssClassName: "yuantisc" 415 | }, 416 | "PingFang TC": { 417 | fontSizes: DefaultFontSizes, 418 | lineHeights: DefaultLineHeights, 419 | cssClassName: "pingfangtc" 420 | }, 421 | "Heiti TC": { 422 | fontSizes: DefaultFontSizes, 423 | lineHeights: DefaultLineHeights, 424 | cssClassName: "heititc" 425 | }, 426 | "Songti TC": { 427 | fontSizes: DefaultFontSizes, 428 | lineHeights: DefaultLineHeights, 429 | cssClassName: "songtitc" 430 | }, 431 | "Kaiti TC": { 432 | fontSizes: DefaultFontSizes, 433 | lineHeights: DefaultLineHeights, 434 | cssClassName: "kaititc" 435 | }, 436 | "Yuanti TC": { 437 | fontSizes: DefaultFontSizes, 438 | lineHeights: DefaultLineHeights, 439 | cssClassName: "yuantitc" 440 | }, 441 | "Apple SD Gothic Neo": { 442 | fontSizes: DefaultFontSizes, 443 | lineHeights: DefaultLineHeights, 444 | cssClassName: "applesdgothicneo" 445 | }, 446 | NanumMyeongjo: { 447 | fontSizes: DefaultFontSizes, 448 | lineHeights: DefaultLineHeights, 449 | cssClassName: "nanummyeongjo" 450 | }, 451 | "Khmer Sangam MN": { 452 | fontSizes: DefaultFontSizes, 453 | lineHeights: DefaultLineHeights, 454 | cssClassName: "khmersangammn" 455 | }, 456 | "Lao Sangam MN": { 457 | fontSizes: DefaultFontSizes, 458 | lineHeights: DefaultLineHeights, 459 | cssClassName: "laosangam" 460 | }, 461 | Thonburi: { 462 | fontSizes: DefaultFontSizes, 463 | lineHeights: DefaultLineHeights, 464 | cssClassName: "thonburi" 465 | }, 466 | Damascus: { 467 | fontSizes: DefaultFontSizes, 468 | lineHeights: DefaultLineHeights, 469 | cssClassName: "damascus" 470 | }, 471 | Kefa: { 472 | fontSizes: DefaultFontSizes, 473 | lineHeights: DefaultLineHeights, 474 | cssClassName: "kefa" 475 | }, 476 | "Arial Hebrew": { 477 | fontSizes: DefaultFontSizes, 478 | lineHeights: DefaultLineHeights, 479 | cssClassName: "arialhebrew" 480 | }, 481 | Mshtakan: { 482 | fontSizes: DefaultFontSizes, 483 | lineHeights: DefaultLineHeights, 484 | cssClassName: "mshtakan" 485 | }, 486 | "Plantagenet Cherokee": { 487 | fontSizes: DefaultFontSizes, 488 | lineHeights: DefaultLineHeights, 489 | cssClassName: "plantagenetcherokee" 490 | }, 491 | "Euphemia UCAS": { 492 | fontSizes: DefaultFontSizes, 493 | lineHeights: DefaultLineHeights, 494 | cssClassName: "euphemiaucas" 495 | }, 496 | "Kohinoor Bangla": { 497 | fontSizes: DefaultFontSizes, 498 | lineHeights: DefaultLineHeights, 499 | cssClassName: "kohinoorbangla" 500 | }, 501 | "Bangla Sangam MN": { 502 | fontSizes: DefaultFontSizes, 503 | lineHeights: DefaultLineHeights, 504 | cssClassName: "banglasangammn" 505 | }, 506 | "Gujarati Sangam MN": { 507 | fontSizes: DefaultFontSizes, 508 | lineHeights: DefaultLineHeights, 509 | cssClassName: "gujarati" 510 | }, 511 | "Gurmukhi MN": { 512 | fontSizes: DefaultFontSizes, 513 | lineHeights: DefaultLineHeights, 514 | cssClassName: "gurmukhi" 515 | }, 516 | "Kohinoor Devanagari": { 517 | fontSizes: DefaultFontSizes, 518 | lineHeights: DefaultLineHeights, 519 | cssClassName: "kohinoordevanagari" 520 | }, 521 | "ITF Devanagari": { 522 | fontSizes: DefaultFontSizes, 523 | lineHeights: DefaultLineHeights, 524 | cssClassName: "itfdevanagari" 525 | }, 526 | "Kannada Sangam MN": { 527 | fontSizes: DefaultFontSizes, 528 | lineHeights: DefaultLineHeights, 529 | cssClassName: "kannada" 530 | }, 531 | "Malayalam Sangam MN": { 532 | fontSizes: DefaultFontSizes, 533 | lineHeights: DefaultLineHeights, 534 | cssClassName: "malayalam" 535 | }, 536 | "Oriya Sangam MN": { 537 | fontSizes: DefaultFontSizes, 538 | lineHeights: DefaultLineHeights, 539 | cssClassName: "oriya" 540 | }, 541 | "Sinhala Sangam MN": { 542 | fontSizes: DefaultFontSizes, 543 | lineHeights: DefaultLineHeights, 544 | cssClassName: "sinhala" 545 | }, 546 | InaiMathi: { 547 | fontSizes: DefaultFontSizes, 548 | lineHeights: DefaultLineHeights, 549 | cssClassName: "inaimathi" 550 | }, 551 | "Tamil Sangam MN": { 552 | fontSizes: DefaultFontSizes, 553 | lineHeights: DefaultLineHeights, 554 | cssClassName: "tamil" 555 | }, 556 | "Kohinoor Telugu": { 557 | fontSizes: DefaultFontSizes, 558 | lineHeights: DefaultLineHeights, 559 | cssClassName: "Kohinoor Telugu" 560 | }, 561 | "Telugu Sangam MN": { 562 | fontSizes: DefaultFontSizes, 563 | lineHeights: DefaultLineHeights, 564 | cssClassName: "telugu" 565 | } 566 | }, 567 | ThemeSettings = { 568 | White: { 569 | cssClassName: "white" 570 | }, 571 | Gray: { 572 | cssClassName: "gray" 573 | }, 574 | Sepia: { 575 | cssClassName: "sepia" 576 | }, 577 | Night: { 578 | cssClassName: "night" 579 | } 580 | }, 581 | ConfigurationVersion = 4, 582 | ShouldSaveConfiguration = { 583 | No: !1, 584 | Yes: !0 585 | }, 586 | ShouldRestoreReadingPosition = { 587 | No: !1, 588 | Yes: !0 589 | }, 590 | MinTextZoomIndex = 0, 591 | MaxTextZoomIndex = 11, 592 | MaximumWidthOfImageExtendingBeyondTextContainer = 1050, 593 | ReaderConfigurationJavaScriptEnabledKey = "javaScriptEnabled"; 594 | ReaderAppearanceController = function() { 595 | this._defaultTextSizeIndexProducer = function() { 596 | return 3 597 | }, this._readerSizeClassProducer = function() { 598 | return "all" 599 | }, this._shouldUsePaperAppearance = function() { 600 | return this.articleWidth() + 140 < this.documentElementWidth() 601 | }, this._canLayOutContentBeyondMainTextColumn = !0, this._defaultFontFamilyName = "System", this._defaultThemeName = "White", this.configuration = {}, this._textSizeIndex = null, this._fontFamilyName = this._defaultFontFamilyName, this._themeName = this._defaultThemeName 602 | }, ReaderAppearanceController.prototype = { 603 | initialize: function() { 604 | this.applyConfiguration(), /Macintosh/g.test(navigator.userAgent) ? document.body.classList.add("mac") : document.body.classList.add("ios") 605 | }, 606 | applyConfiguration: function(e) { 607 | var t = this._validConfigurationAndValidityFromUntrustedConfiguration(e), 608 | n = t[0], 609 | i = t[1], 610 | a = n.fontSizeIndexForSizeClass[this._readerSizeClassProducer()]; 611 | textSizeIndexIsValid(a) ? this.setCurrentTextSizeIndex(a, ShouldSaveConfiguration.No) : (this.setCurrentTextSizeIndex(this._defaultTextSizeIndexProducer(), ShouldSaveConfiguration.No), i = !1); 612 | var o = this._locale(), 613 | r = n.fontFamilyNameForLanguageTag[o]; 614 | r && FontSettings[r] || (r = this._defaultFontFamilyNameForLanguage(o), i = !1), this.setFontFamily(r, ShouldSaveConfiguration.No), this.setTheme(n.themeName, ShouldSaveConfiguration.No), this.configuration = n, i || this._updateSavedConfiguration() 615 | }, 616 | _validConfigurationAndValidityFromUntrustedConfiguration: function(e) { 617 | var t = { 618 | fontSizeIndexForSizeClass: {}, 619 | fontFamilyNameForLanguageTag: {}, 620 | themeName: null 621 | }, 622 | n = !0; 623 | e || (e = {}, n = !1); 624 | var i = (e || {}).version; 625 | (!i || "number" != typeof i || ConfigurationVersion > i) && (e = {}, n = !1); 626 | var a = (e || {}).fontSizeIndexForSizeClass; 627 | if (a && "object" == typeof a) 628 | for (var o in a) { 629 | var r = a[o]; 630 | textSizeIndexIsValid(r) ? t.fontSizeIndexForSizeClass[o] = r : n = !1 631 | } 632 | else 633 | n = !1; 634 | var s = e.fontFamilyNameForLanguageTag; 635 | s && "object" == typeof s ? t.fontFamilyNameForLanguageTag = s : (t.fontFamilyNameForLanguageTag = {}, n = !1); 636 | var l = e.themeName; 637 | return l && "string" == typeof l && ThemeSettings[l] ? t.themeName = l : (t.themeName = this._defaultThemeName, n = !1), [t, n] 638 | }, 639 | _updateSavedConfiguration: function() { 640 | this.configuration.fontSizeIndexForSizeClass[this._readerSizeClassProducer()] = this._textSizeIndex, this.configuration.fontFamilyNameForLanguageTag[this._locale()] = this._fontFamilyName, this.configuration.themeName = this._themeName; 641 | var e = this.configuration; 642 | e.version = ConfigurationVersion 643 | }, 644 | applyAppropriateFontSize: function() { 645 | var e = this.configuration.fontSizeIndexForSizeClass[this._readerSizeClassProducer()]; 646 | e && this.setCurrentTextSizeIndex(e, ShouldSaveConfiguration.No) 647 | }, 648 | makeTextLarger: function() { 649 | this._textSizeIndex < this._currentFontSettings().fontSizes.length - 1 && this.setCurrentTextSizeIndex(this._textSizeIndex + 1, ShouldSaveConfiguration.Yes) 650 | }, 651 | makeTextSmaller: function() { 652 | this._textSizeIndex > 0 && this.setCurrentTextSizeIndex(this._textSizeIndex - 1, ShouldSaveConfiguration.Yes) 653 | }, 654 | articleWidth: function() { 655 | return document.getElementById("article").getBoundingClientRect().width 656 | }, 657 | _textColumnWidthInPoints: function() { 658 | return parseFloat(getComputedStyle(document.querySelector("#article .page")).width) 659 | }, 660 | documentElementWidth: function() { 661 | return document.documentElement.clientWidth 662 | }, 663 | setCurrentTextSizeIndex: function(e, t) { 664 | e !== this._textSizeIndex && (this._textSizeIndex = e, this._rebuildDynamicStyleSheet(), this.layOutContent(), t === ShouldSaveConfiguration.Yes && this._updateSavedConfiguration()) 665 | }, 666 | currentFontCSSClassName: function() { 667 | return this._currentFontSettings().cssClassName 668 | }, 669 | _currentFontSettings: function() { 670 | return FontSettings[this._fontFamilyName] 671 | }, 672 | setFontFamily: function(e, t) { 673 | var n = document.body, 674 | i = FontSettings[e]; 675 | n.classList.contains(i.cssClassName) || (this._fontFamilyName && n.classList.remove(FontSettings[this._fontFamilyName].cssClassName), n.classList.add(i.cssClassName), this._fontFamilyName = e, this.layOutContent(), t === ShouldSaveConfiguration.Yes && this._updateSavedConfiguration()) 676 | }, 677 | _theme: function() { 678 | return ThemeSettings[this._themeName] 679 | }, 680 | setTheme: function(e, t) { 681 | var n = document.body, 682 | i = ThemeSettings[e]; 683 | n.classList.contains(i.cssClassName) || (this._theme() && n.classList.remove(this._theme().cssClassName), n.classList.add(i.cssClassName), this._themeName = e, t === ShouldSaveConfiguration.Yes && this._updateSavedConfiguration()) 684 | }, 685 | usesPaperAppearance: function() { 686 | return document.documentElement.classList.contains("paper") 687 | }, 688 | layOutContent: function(e) { 689 | void 0 === e && (e = ShouldRestoreReadingPosition.Yes), this._shouldUsePaperAppearance() ? document.documentElement.classList.add("paper") : document.documentElement.classList.remove("paper"), makeWideElementsScrollable(), this._canLayOutContentBeyondMainTextColumn && (this._layOutImagesBeyondTextColumn(), this._layOutElementsContainingTextBeyondTextColumn(), this._layOutVideos()), e === ShouldRestoreReadingPosition.Yes && ReadingPositionStabilizerJS.restorePosition() 690 | }, 691 | _layOutImagesBeyondTextColumn: function() { 692 | for (var e = this.canLayOutContentMaintainingAspectRatioBeyondTextColumn(), t = article.querySelectorAll("img"), n = t.length, i = 0; n > i; ++i) 693 | this.setImageShouldLayOutBeyondTextColumnIfAppropriate(t[i], e) 694 | }, 695 | _layOutElementsContainingTextBeyondTextColumn: function() { 696 | const e = { 697 | PRE: !0, 698 | TABLE: !1 699 | }, 700 | t = 22; 701 | for (var n = document.querySelectorAll(".scrollable pre, .scrollable table"), i = n.length, a = 0; i > a; ++a) { 702 | for (var o = n[a], r = o.parentElement, s = r; s; s = s.parentElement) 703 | "BLOCKQUOTE" === s.tagName && s.classList.add("simple"); 704 | stopExtendingElementBeyondTextColumn(r); 705 | var l = o.scrollWidth, 706 | d = this._textColumnWidthInPoints(); 707 | if (!(d >= l)) { 708 | var c = getComputedStyle(document.querySelector(".page")), 709 | u = 0; 710 | if (e[o.tagName]) { 711 | var m = parseFloat(c["-webkit-padding-start"]) + parseFloat(c["-webkit-margin-start"]); 712 | u = Math.min(m, t) 713 | } 714 | var g = Math.min(l, this._widthAvailableForLayout() - 2 * u); 715 | extendElementBeyondTextColumn(r, g, d) 716 | } 717 | } 718 | }, 719 | _layOutVideos: function() { 720 | function e(e) { 721 | return e.src && /^(.+\.)?youtube\.com\.?$/.test(anchorForURL(e.src).hostname) 722 | } 723 | const t = 16 / 9; 724 | for (var n = article.querySelectorAll("iframe"), i = n.length, a = 0; i > a; ++a) { 725 | var o = n[a]; 726 | e(o) && (o.style.width = "100%", o.style.height = this._textColumnWidthInPoints() / t + "px") 727 | } 728 | }, 729 | canLayOutContentMaintainingAspectRatioBeyondTextColumn: function() { 730 | const e = 700; 731 | if (window.innerHeight >= e) 732 | return !0; 733 | const t = 1.25; 734 | return window.innerWidth / window.innerHeight <= t 735 | }, 736 | setImageShouldLayOutBeyondTextColumnIfAppropriate: function(e, t) { 737 | if (t && !e.closest("blockquote, table, .float")) { 738 | var n, 739 | i = this._textColumnWidthInPoints(), 740 | a = parseFloat(e.getAttribute("width")); 741 | n = isNaN(a) ? e.naturalWidth : a; 742 | var o = Math.min(n, Math.min(MaximumWidthOfImageExtendingBeyondTextContainer, this._widthAvailableForLayout())); 743 | if (o > i) 744 | return void extendElementBeyondTextColumn(e, o, i) 745 | } 746 | stopExtendingElementBeyondTextColumn(e) 747 | }, 748 | _widthAvailableForLayout: function() { 749 | return this.usesPaperAppearance() ? this.articleWidth() : this.documentElementWidth() 750 | }, 751 | _rebuildDynamicStyleSheet: function() { 752 | for (var e = document.getElementById("dynamic-article-content").sheet; e.cssRules.length;) 753 | e.removeRule(0); 754 | var t = this._currentFontSettings().fontSizes[this._textSizeIndex] + "px", 755 | n = this._currentFontSettings().lineHeights[this._textSizeIndex]; 756 | e.insertRule("#article { font-size: " + t + "; line-height: " + n + "; }") 757 | }, 758 | _locale: function() { 759 | var e = document.getElementById("article").style.webkitLocale; 760 | return e && e.length ? e : "" 761 | }, 762 | _defaultFontFamilyNameForLanguage: function(e) { 763 | const t = { 764 | am: "Kefa", 765 | ar: "Damascus", 766 | hy: "Mshtakan", 767 | bn: "Kohinoor Bangla", 768 | chr: "Plantagenet Cherokee", 769 | gu: "Gujarati Sangam MN", 770 | "pa-Guru": "Gurmukhi MN", 771 | he: "Arial Hebrew", 772 | hi: "Kohinoor Devanagari", 773 | ja: "Hiragino Mincho ProN", 774 | kn: "Kannada Sangam MN", 775 | km: "Khmer Sangam MN", 776 | ko: "Apple SD Gothic Neo", 777 | lo: "Lao Sangam MN", 778 | ml: "Malayalam Sangam MN", 779 | or: "Oriya Sangam MN", 780 | si: "Sinhala Sangam MN", 781 | ta: "InaiMathi", 782 | te: "Kohinoor Telugu", 783 | th: "Thonburi", 784 | "zh-Hans": "PingFang SC", 785 | "zh-Hant": "PingFang TC", 786 | "iu-Cans": "Euphemia UCAS" 787 | }; 788 | var n = t[e]; 789 | return n ? n : this._defaultFontFamilyName 790 | } 791 | }; 792 | var lastMouseDownWasOutsideOfPaper = !1; 793 | ReaderController = function() { 794 | this.pageNumber = 1, this.pageURLs = [], this.articleIsLTR = !0, this.loadingNextPage = !1, this.loadingNextPageManuallyStopped = !1, this.cachedNextPageURL = null, this.lastKnownUserVisibleWidth = 0, this.lastKnownDocumentElementWidth = 0, this._readerWillBecomeVisible = function() {}, this._readerWillEnterBackground = function() {}, this._distanceFromBottomOfArticleToStartLoadingNextPage = function() { 795 | return NaN 796 | }, this._shouldRestoreScrollPositionFromOriginalPageAtActivation = !1, this._clickingOutsideOfPaperRectangleDismissesReader = !1, this._shouldSkipActivationWhenPageLoads = function() { 797 | return !1 798 | }, this._shouldConvertRelativeURLsToAbsoluteURLsWhenPrintingOrMailing = !1, this._deferSendingContentIsReadyForDisplay = !1, this._isJavaScriptEnabled = function() { 799 | return !0 800 | } 801 | }, ReaderController.prototype = { 802 | setOriginalURL: function(e) { 803 | this.originalURL = e, this.pageURLs.push(e), document.head.getElementsByTagName("base")[0].href = this.originalURL 804 | }, 805 | setNextPageURL: function(e) { 806 | if (!e || -1 !== this.pageURLs.indexOf(e) || this.pageNumber + 1 === MaxNumberOfNextPagesToLoad) 807 | return void this.setLoadingNextPage(!1); 808 | this.setLoadingNextPage(!0), this.pageURLs.push(e); 809 | var t = function() { 810 | nextPageContainer().addEventListener("load", nextPageLoadComplete, !1), nextPageContainer().src = e 811 | }; 812 | this.readerOperationMode == ReaderOperationMode.OffscreenFetching ? t() : this.nextPageLoadTimer = setTimeout(t, LoadNextPageDelay) 813 | }, 814 | pauseLoadingNextPage: function() { 815 | }, 816 | stopLoadingNextPage: function() { 817 | nextPageContainer().removeEventListener("load", nextPageLoadComplete, !1), nextPageContainer().src = null, this.nextPageLoadTimer && clearTimeout(this.nextPageLoadTimer), this.isLoadingNextPage() && (this.setLoadingNextPage(!1), this.loadingNextPageManuallyStopped = !0) 818 | }, 819 | isLoadingNextPage: function() { 820 | return this.loadingNextPage 821 | }, 822 | setLoadingNextPage: function(e) { 823 | this.loadingNextPage != e && (removeIncomingPagePlaceholder(), this.loadingNextPage = e) 824 | }, 825 | doneLoadingAllPages: function() { 826 | }, 827 | loaded: function() { 828 | if (!ReaderArticleFinderJS || this._shouldSkipActivationWhenPageLoads()) 829 | return null; 830 | if (this.loadArticle(), ReaderAppearanceJS.initialize(), ReadingPositionStabilizerJS.initialize(), this._shouldRestoreScrollPositionFromOriginalPageAtActivation) { 831 | var e = 0; 832 | if (e > 0) 833 | document.body.scrollTop = e; 834 | else { 835 | var t = document.getElementById("safari-reader-element-marker"); 836 | if (t) { 837 | var n = parseFloat(t.style.top) / 100, 838 | i = t.parentElement, 839 | a = i.getBoundingClientRect(); 840 | document.body.scrollTop = window.scrollY + a.top + a.height * n, i.removeChild(t) 841 | } 842 | } 843 | } 844 | this._clickingOutsideOfPaperRectangleDismissesReader && (document.documentElement.addEventListener("mousedown", monitorMouseDownForPotentialDeactivation), document.documentElement.addEventListener("click", deactivateIfEventIsOutsideOfPaperContainer)); 845 | var o = function() { 846 | this.setUserVisibleWidth(this.lastKnownUserVisibleWidth) 847 | }.bind(this); 848 | window.addEventListener("resize", o, !1); 849 | 850 | var article_node = document.getElementById("article"); 851 | article_node.firstChild.remove(); 852 | 853 | var message = { 'code' : 0 }; 854 | window.webkit.messageHandlers.JSController.postMessage(message); 855 | }, 856 | setUserVisibleWidth: function(e) { 857 | var t = ReaderAppearanceJS.documentElementWidth(); 858 | e === this.lastKnownUserVisibleWidth && t === this.lastKnownDocumentElementWidth || (this.lastKnownUserVisibleWidth = e, this.lastKnownDocumentElementWidth = t, ReaderAppearanceJS.applyAppropriateFontSize(), ReaderAppearanceJS.layOutContent()) 859 | }, 860 | loadArticle: function() { 861 | var e = ReaderArticleFinderJS; 862 | e.findArticle(); 863 | if (e.article || e.articleNode(!0), !e.article) 864 | return this.setOriginalURL(e.contentDocument.baseURI), void this.doneLoadingAllPages(); 865 | this.routeToArticle = e.routeToArticleNode(), this.displayTitle = e.articleTitle(), this.displaySubhead = "", this.articleIsLTR = e.articleIsLTR(); 866 | var t = e.adoptableArticle().ownerDocument; 867 | if (document.title = t.title, this.setOriginalURL(t.baseURI), this.readerOperationMode == ReaderOperationMode.ArchiveViewing) 868 | return void ReaderAppearanceJS.layOutContent(); 869 | var n = e.adoptableArticle(); 870 | if (this._isJavaScriptEnabled()) { 871 | var i = e.nextPageURL(); 872 | this.setNextPageURL(i) 873 | } else { 874 | for (var a = n.querySelectorAll("iframe"), o = a.length, r = 0; o > r; ++r) 875 | a[r].remove(); 876 | this.stopLoadingNextPage() 877 | } 878 | this.updateLocaleFromElement(n), this.createPageFromNode(n), i 879 | }, 880 | loadNewArticle: function() { 881 | if (!ReaderArticleFinderJS) 882 | return null; 883 | for (var e = document.getElementById("article"); e.childNodes.length >= 1;) 884 | e.removeChild(e.firstChild); 885 | this.reinitialize(), document.body.scrollTop = 0, this.loadArticle() 886 | }, 887 | reinitialize: function() { 888 | this.pageNumber = 1, this.pageURLs = [], this.articleIsLTR = !0, this.loadingNextPage = !1, this.loadingNextPageManuallyStopped = !1, this.routeToArticle = void 0, this.displayTitle = void 0, this.displaySubhead = void 0, this.originalURL = void 0, this.nextPageLoadTimer = void 0, this.cachedNextPageURL = null 889 | }, 890 | createPageFromNode: function(e) { 891 | var t = document.createElement("div"); 892 | t.className = "page", this.articleIsLTR || t.classList.add("rtl"); 893 | var n = document.createElement("div"); 894 | n.className = "page-number", t.appendChild(n); 895 | var i = document.createElement("h1"); 896 | if (i.className = "title", i.textContent = this.displayTitle, t.appendChild(i), this.displaySubhead) { 897 | var a = document.createElement("h2"); 898 | a.className = "subhead", a.textContent = this.displaySubhead, t.appendChild(a) 899 | } 900 | if (this.metadataElement && this.metadataElement.innerText) { 901 | var o = document.createElement("div"); 902 | for (o.className = "metadata"; this.metadataElement.firstChild;) 903 | o.appendChild(this.metadataElement.firstChild); 904 | t.appendChild(o) 905 | } 906 | for (; e.firstChild;) 907 | t.appendChild(e.firstChild); 908 | var r = document.getElementById("article"); 909 | r.insertBefore(t, incomingPagePlaceholder()), replaceSimpleTweetsWithRichTweets(), ReaderAppearanceJS.layOutContent(ShouldRestoreReadingPosition.No), updatePageNumbers(), restoreInitialArticleScrollPositionIfPossible(); 910 | for (var s = t.querySelectorAll("img"), l = s.length, d = 0; l > d; ++d) 911 | s[d].onload = function(e) { 912 | var t = e.target; 913 | ReaderAppearanceJS.setImageShouldLayOutBeyondTextColumnIfAppropriate(t, ReaderAppearanceJS.canLayOutContentMaintainingAspectRatioBeyondTextColumn()), t.onload = null 914 | }; 915 | this._fixImageElementsWithinPictureElements() 916 | }, 917 | removeAttribute: function(e, t) { 918 | for (var n = e.querySelectorAll("[" + t + "]"), i = n.length, a = 0; i > a; a++) 919 | n[a].removeAttribute(t) 920 | }, 921 | preparePrintingMailingFrame: function() { 922 | var e = this.printingMailingFrameElementId(), 923 | t = document.getElementById(e); 924 | t && document.body.removeChild(t), t = document.createElement("iframe"), t.id = e, t.style.display = "none", t.style.position = "absolute", document.body.appendChild(t); 925 | var n = t.contentDocument, 926 | i = document.createElement("base"); 927 | i.href = this.originalURL, n.head.appendChild(i); 928 | var a = document.createElement("div"); 929 | a.className = "original-url"; 930 | var o = document.createElement("a"); 931 | o.href = this.originalURL, o.textContent = this.originalURL, a.appendChild(document.createElement("br")), a.appendChild(o), a.appendChild(document.createElement("br")), a.appendChild(document.createElement("br")), n.body.appendChild(a), n.body.appendChild(this.sanitizedFullArticle()), n.head.appendChild(document.getElementById("print").cloneNode(!0)); 932 | var r = n.createElement("title"); 933 | r.innerText = document.title, n.head.appendChild(r) 934 | }, 935 | sanitizedFullArticle: function() { 936 | var e = document.getElementById("article").cloneNode(!0); 937 | e.removeAttribute("tabindex"); 938 | for (var t = e.querySelectorAll(".title"), n = 1; n < t.length; ++n) 939 | t[n].remove(); 940 | for (var i = e.querySelectorAll(".page-number, #incoming-page-placeholder"), n = 0; n < i.length; ++n) 941 | i[n].remove(); 942 | if (prepareTweetsInPrintingMailingFrame(e), this._shouldConvertRelativeURLsToAbsoluteURLsWhenPrintingOrMailing) { 943 | var a = e.querySelectorAll("img, video, audio, source"); 944 | const o = /^http:\/\/|^https:\/\/|^data:/i; 945 | for (var n = 0; n < a.length; n++) { 946 | var r = a[n], 947 | s = r.getAttribute("src"); 948 | o.test(s) || r.setAttribute("src", r.src) 949 | } 950 | } 951 | for (var l = e.querySelectorAll(".extendsBeyondTextColumn"), d = l.length, n = 0; d > n; ++n) 952 | stopExtendingElementBeyondTextColumn(l[n]); 953 | for (var c = e.querySelectorAll(".delimeter"), u = c.length, n = 0; u > n; ++n) 954 | c[n].innerText = "\u2022"; 955 | e.classList.add(ReaderAppearanceJS.currentFontCSSClassName()), e.classList.add("exported"); 956 | for (var m = document.getElementById("article-content").sheet.cssRules, g = m.length, h = 0; g > h; ++h) { 957 | var p = m[h].selectorText, 958 | f = m[h].style; 959 | if (f) { 960 | var S = f.cssText; 961 | e.matches(p) && (e.style.cssText += S); 962 | for (var C = e.querySelectorAll(p), x = C.length, v = 0; x > v; ++v) 963 | C[v].style.cssText += S 964 | } 965 | } 966 | return e 967 | }, 968 | printingMailingFrameElementId: function() { 969 | return "printing-mailing-frame" 970 | }, 971 | updateLocaleFromElement: function(e) { 972 | this._bestLocale = localeForElement(e), document.getElementById("article").style.webkitLocale = "'" + this._bestLocale + "'" 973 | }, 974 | canLoadNextPage: function() { 975 | if (this.readerOperationMode != ReaderOperationMode.Normal) 976 | return !0; 977 | var e = document.querySelectorAll(".page"), 978 | t = e[e.length - 1], 979 | n = t.getBoundingClientRect(), 980 | i = this._distanceFromBottomOfArticleToStartLoadingNextPage(); 981 | return isNaN(i) ? !0 : !(n.bottom - window.scrollY > i) 982 | }, 983 | setCachedNextPageURL: function(e) { 984 | e ? null : this.setNextPageURL(e) 985 | }, 986 | loadNextPage: function() { 987 | null != this.cachedNextPageURL && (this.setNextPageURL(this.cachedNextPageURL), this.cachedNextPageURL = null ) 988 | }, 989 | resumeCachedNextPageLoadIfNecessary: function() { 990 | ReaderJS.cachedNextPageURL && ReaderJS.canLoadNextPage() && ReaderJS.loadNextPage() 991 | }, 992 | readerWillBecomeVisible: function() { 993 | document.body.classList.remove("cached"), this.resumeCachedNextPageLoadIfNecessary(), this._readerWillBecomeVisible() 994 | }, 995 | readerWillEnterBackground: function() { 996 | (ReaderJS.isLoadingNextPage() || ReaderJS.loadingNextPageManuallyStopped) && this.pauseLoadingNextPage(); 997 | for (var e = document.querySelectorAll("audio, video"), t = 0, n = e.length; n > t; ++t) 998 | e[t].pause(); 999 | document.body.classList.add("cached"), this._readerWillEnterBackground() 1000 | }, 1001 | _fixImageElementsWithinPictureElements: function() { 1002 | setTimeout(function() { 1003 | for (var e = !1, t = document.querySelectorAll("#article picture img"), n = t.length, i = 0; n > i; ++i) { 1004 | var a = t[i], 1005 | o = a.previousElementSibling; 1006 | o && (a.remove(), o.after(a), e = !0) 1007 | } 1008 | e && ReaderAppearanceJS.layOutContent() 1009 | }, 0) 1010 | } 1011 | }, ReadingPositionStabilizer = function() { 1012 | this.elementTouchingTopOfViewport = null, this.elementTouchingTopOfViewportOffsetFromTopOfElementRatio = 0 1013 | }, ReadingPositionStabilizer.prototype = { 1014 | initialize: function() { 1015 | this.setTrackPosition(!0) 1016 | }, 1017 | setTrackPosition: function(e) { 1018 | this._positionUpdateFunction || (this._positionUpdateFunction = this._updatePosition.bind(this)), e ? window.addEventListener("scroll", this._positionUpdateFunction, !1) : window.removeEventListener("scroll", this._positionUpdateFunction, !1) 1019 | }, 1020 | _updatePosition: function() { 1021 | var e = contentElementTouchingTopOfViewport(); 1022 | if (!e) 1023 | return void (this.elementTouchingTopOfViewport = null); 1024 | this.elementTouchingTopOfViewport = e; 1025 | var t = this.elementTouchingTopOfViewport.getBoundingClientRect(); 1026 | this.elementTouchingTopOfViewportOffsetFromTopOfElementRatio = t.height > 0 ? t.top / t.height : 0 1027 | }, 1028 | restorePosition: function() { 1029 | if (this.elementTouchingTopOfViewport) { 1030 | var e = this.elementTouchingTopOfViewport.getBoundingClientRect(), 1031 | t = document.body.scrollTop + e.top - e.height * this.elementTouchingTopOfViewportOffsetFromTopOfElementRatio; 1032 | t > 0 && (document.body.scrollTop = t), this._updatePosition() 1033 | } 1034 | } 1035 | }; 1036 | var ContentAwareScrollerJS = new ContentAwareScroller, 1037 | ReaderAppearanceJS = new ReaderAppearanceController, 1038 | ReadingPositionStabilizerJS = new ReadingPositionStabilizer, 1039 | ReaderJS = new ReaderController; 1040 | -------------------------------------------------------------------------------- /Classes/PFWebViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFWebViewController.h 3 | // PFWebViewController 4 | // 5 | // Created by Cee on 9/19/16. 6 | // Copyright © 2016 Cee. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PFWebViewController : UIViewController 12 | 13 | @property (nonatomic, strong) NSURL *url; 14 | @property (nonatomic, strong) UIColor *progressBarColor; 15 | 16 | // Init Method 17 | - (id)initWithURL:(NSURL *)url; 18 | - (id)initWithURLString:(NSString *)urlString; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Classes/PFWebViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PFWebViewController.m 3 | // PFWebViewController 4 | // 5 | // Created by Cee on 9/19/16. 6 | // Copyright © 2016 Cee. All rights reserved. 7 | // 8 | 9 | #import "PFWebViewController.h" 10 | #import "PFWebViewNavigationHeader.h" 11 | #import "PFWebViewToolBar.h" 12 | #import 13 | 14 | #define SCREENWIDTH [UIScreen mainScreen].bounds.size.width 15 | #define SCREENHEIGHT [UIScreen mainScreen].bounds.size.height 16 | 17 | @interface PFWebViewController () { 18 | BOOL isNavigationBarHidden; 19 | BOOL isReaderMode; 20 | 21 | NSString *readerHTMLString; 22 | NSString *readerArticleTitle; 23 | } 24 | 25 | @property (nonatomic, assign) CGFloat offset; 26 | @property (nonatomic, strong) WKWebView *webView; 27 | @property (nonatomic, strong) UIView *webMaskView; 28 | @property (nonatomic, strong) CALayer *maskLayer; 29 | 30 | @property (nonatomic, strong) WKWebView *readerWebView; 31 | @property (nonatomic, strong) PFWebViewNavigationHeader *navigationHeader; 32 | @property (nonatomic, strong) PFWebViewToolBar *toolbar; 33 | @property (nonatomic, strong) UIProgressView *progressView; 34 | 35 | @end 36 | 37 | @implementation PFWebViewController 38 | 39 | #pragma mark - Life Cycle 40 | 41 | - (id)initWithURL:(NSURL *)url { 42 | 43 | self.offset = SCREENWIDTH < SCREENHEIGHT ? 20.f : 0.f; 44 | 45 | self = [super init]; 46 | if (self) { 47 | self.url = url; 48 | self.progressBarColor = [UIColor blackColor]; 49 | } 50 | return self; 51 | } 52 | 53 | - (id)initWithURLString:(NSString *)urlString { 54 | 55 | self.offset = SCREENWIDTH < SCREENHEIGHT ? 20.f : 0.f; 56 | 57 | self = [super init]; 58 | if (self) { 59 | self.url = [NSURL URLWithString:urlString]; 60 | self.progressBarColor = [UIColor blackColor]; 61 | } 62 | return self; 63 | } 64 | 65 | - (void)viewDidLoad { 66 | [super viewDidLoad]; 67 | // [WebConsole enable]; 68 | 69 | self.view.backgroundColor = [UIColor whiteColor]; 70 | 71 | [self.view addSubview:self.navigationHeader]; 72 | [self.view addSubview:self.toolbar]; 73 | [self.view addSubview:self.progressView]; 74 | 75 | [self setupReaderMode]; 76 | [self.toolbar setup]; 77 | 78 | [self loadWebContent]; 79 | } 80 | 81 | - (void)loadWebContent { 82 | if (self.url) { 83 | [self.webView loadRequest:[NSURLRequest requestWithURL:self.url]]; 84 | return; 85 | } 86 | } 87 | 88 | - (void)viewWillAppear:(BOOL)animated { 89 | [super viewWillAppear:animated]; 90 | [self.webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil]; 91 | [self.webView addObserver:self forKeyPath:@"canGoBack" options:NSKeyValueObservingOptionNew context:nil]; 92 | [self.webView addObserver:self forKeyPath:@"canGoForward" options:NSKeyValueObservingOptionNew context:nil]; 93 | [self.webView addObserver:self forKeyPath:@"URL" options:NSKeyValueObservingOptionNew context:nil]; 94 | 95 | if (self.navigationController) { 96 | isNavigationBarHidden = self.navigationController.navigationBar.hidden; 97 | [self.navigationController setNavigationBarHidden:YES]; 98 | } 99 | } 100 | 101 | - (void)viewWillDisappear:(BOOL)animated { 102 | [super viewWillDisappear:animated]; 103 | [self.webView removeObserver:self forKeyPath:@"estimatedProgress"]; 104 | [self.webView removeObserver:self forKeyPath:@"canGoBack"]; 105 | [self.webView removeObserver:self forKeyPath:@"canGoForward"]; 106 | [self.webView removeObserver:self forKeyPath:@"URL"]; 107 | 108 | if (self.navigationController) { 109 | [self.navigationController setNavigationBarHidden:isNavigationBarHidden]; 110 | } 111 | } 112 | 113 | - (void)viewDidLayoutSubviews { 114 | [super viewDidLayoutSubviews]; 115 | 116 | self.offset = SCREENWIDTH < SCREENHEIGHT ? 20.f : 0.f; 117 | 118 | self.webView.frame = CGRectMake(0, self.offset + 20.5f, SCREENWIDTH, SCREENHEIGHT - 50.5f - 20.5f - self.offset); 119 | self.navigationHeader.frame = CGRectMake(0, 0, SCREENWIDTH, self.offset + 20.5f); 120 | self.toolbar.frame = CGRectMake(0, SCREENHEIGHT - 50.5f, SCREENWIDTH, 50.5f); 121 | self.progressView.frame = CGRectMake(0, 19 + self.offset, SCREENWIDTH, 2); 122 | 123 | self.webMaskView.frame = self.webView.frame; 124 | self.readerWebView.frame = self.webView.frame; 125 | self.maskLayer.frame = CGRectMake(0.0f, 0.0f, _readerWebView.frame.size.width, self.maskLayer.bounds.size.height); 126 | } 127 | 128 | #pragma mark - Lazy Initialize 129 | 130 | - (WKWebView *)webView { 131 | if (!_webView) { 132 | _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, self.offset + 20.5f, SCREENWIDTH, SCREENHEIGHT - 50.5f - 20.5f - self.offset) configuration:[self configuration]]; 133 | _webView.allowsBackForwardNavigationGestures = YES; 134 | _webView.navigationDelegate = self; 135 | } 136 | return _webView; 137 | } 138 | 139 | - (UIView *)webMaskView { 140 | if (!_webMaskView) { 141 | _webMaskView = [[UIView alloc] initWithFrame:self.webView.frame]; 142 | _webMaskView.backgroundColor = [UIColor clearColor]; 143 | _webMaskView.userInteractionEnabled = NO; 144 | } 145 | return _webMaskView; 146 | } 147 | 148 | - (WKWebView *)readerWebView { 149 | if (!_readerWebView) { 150 | _readerWebView = [[WKWebView alloc] initWithFrame:self.webView.frame configuration:[self configuration]]; 151 | _readerWebView.allowsBackForwardNavigationGestures = NO; 152 | _readerWebView.navigationDelegate = self; 153 | _readerWebView.userInteractionEnabled = NO; 154 | _readerWebView.layer.masksToBounds = YES; 155 | } 156 | return _readerWebView; 157 | } 158 | 159 | - (PFWebViewNavigationHeader *)navigationHeader { 160 | if (!_navigationHeader) { 161 | _navigationHeader = [[PFWebViewNavigationHeader alloc] initWithURL:self.url]; 162 | } 163 | return _navigationHeader; 164 | } 165 | 166 | - (PFWebViewToolBar *)toolbar { 167 | if (!_toolbar) { 168 | _toolbar = [[PFWebViewToolBar alloc] initWithFrame:CGRectMake(0, SCREENHEIGHT - 50.5f, SCREENWIDTH, 50.5f)]; 169 | _toolbar.delegate = self; 170 | } 171 | return _toolbar; 172 | } 173 | 174 | - (UIProgressView *)progressView { 175 | if (!_progressView) { 176 | _progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(0, self.offset + 19.f, SCREENWIDTH, 2)]; 177 | _progressView.trackTintColor = [UIColor clearColor]; 178 | _progressView.progressTintColor = self.progressBarColor; 179 | } 180 | return _progressView; 181 | } 182 | 183 | #pragma mark - Reader Mode 184 | 185 | - (void)setupReaderMode { 186 | isReaderMode = NO; 187 | [self.view addSubview:self.webView]; 188 | [self.view addSubview:self.webMaskView]; 189 | 190 | self.maskLayer = [CALayer layer]; 191 | self.maskLayer.frame = CGRectMake(0.0f, 0.0f, self.readerWebView.frame.size.width, 0.0f); 192 | self.maskLayer.borderWidth = self.readerWebView.frame.size.height / 2.0f; 193 | self.maskLayer.anchorPoint = CGPointMake(0.5, 1.0f); 194 | 195 | [self.readerWebView.layer setMask:self.maskLayer]; 196 | 197 | [self.view addSubview:self.readerWebView]; 198 | } 199 | 200 | #pragma mark - KVO 201 | 202 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 203 | 204 | if ([keyPath isEqualToString:@"estimatedProgress"]) { 205 | if ([change[NSKeyValueChangeNewKey] isKindOfClass:[NSNumber class]]) { 206 | [self progressChanged:change[NSKeyValueChangeNewKey]]; 207 | } 208 | } else if ([keyPath isEqualToString:@"canGoBack"]){ 209 | if ([self.webView canGoBack]) { 210 | self.toolbar.backBtn.enabled = YES; 211 | } else { 212 | self.toolbar.backBtn.enabled = NO; 213 | } 214 | } else if ([keyPath isEqualToString:@"canGoForward"]){ 215 | if ([self.webView canGoForward]) { 216 | self.toolbar.forwardBtn.enabled = YES; 217 | } else { 218 | self.toolbar.forwardBtn.enabled = NO; 219 | } 220 | } else if ([keyPath isEqualToString:@"URL"]){ 221 | [self.navigationHeader setURL:self.webView.URL]; 222 | } 223 | 224 | } 225 | 226 | #pragma mark - Private 227 | 228 | - (void)progressChanged:(NSNumber *)newValue { 229 | if (self.progressView.alpha == 0) { 230 | self.progressView.alpha = 1.f; 231 | } 232 | 233 | [self.progressView setProgress:newValue.floatValue animated:YES]; 234 | 235 | if (self.progressView.progress == 1) { 236 | [UIView animateWithDuration:.5f animations:^{ 237 | self.progressView.alpha = 0; 238 | } completion:^(BOOL finished) { 239 | self.progressView.progress = 0; 240 | }]; 241 | } else if (self.progressView.alpha == 0){ 242 | [UIView animateWithDuration:.1f animations:^{ 243 | self.progressView.alpha = 1.f; 244 | }]; 245 | } 246 | } 247 | 248 | - (WKWebViewConfiguration *)configuration { 249 | // Load reader mode js script 250 | NSBundle *bundle = [NSBundle bundleForClass:[self class]]; 251 | NSURL *url = [bundle URLForResource:@"PFWebViewController" withExtension:@"bundle"]; 252 | NSBundle *imageBundle = [NSBundle bundleWithURL:url]; 253 | 254 | NSString *readerScriptFilePath = [imageBundle pathForResource:@"safari-reader" ofType:@"js"]; 255 | NSString *readerCheckScriptFilePath = [imageBundle pathForResource:@"safari-reader-check" ofType:@"js"]; 256 | 257 | NSString *indexPageFilePath = [imageBundle pathForResource:@"index" ofType:@"html"]; 258 | 259 | // Load HTML for reader mode 260 | readerHTMLString = [[NSString alloc] initWithContentsOfFile:indexPageFilePath encoding:NSUTF8StringEncoding error:nil]; 261 | 262 | NSString *script = [[NSString alloc] initWithContentsOfFile:readerScriptFilePath encoding:NSUTF8StringEncoding error:nil]; 263 | WKUserScript *userScript = [[WKUserScript alloc] initWithSource:script injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:NO]; 264 | 265 | NSString *check_script = [[NSString alloc] initWithContentsOfFile:readerCheckScriptFilePath encoding:NSUTF8StringEncoding error:nil]; 266 | WKUserScript *check_userScript = [[WKUserScript alloc] initWithSource:check_script injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:NO]; 267 | 268 | WKUserContentController *userContentController = [[WKUserContentController alloc] init]; 269 | [userContentController addUserScript:userScript]; 270 | [userContentController addUserScript:check_userScript]; 271 | [userContentController addScriptMessageHandler:self name:@"JSController"]; 272 | 273 | WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init]; 274 | configuration.userContentController = userContentController; 275 | 276 | return configuration; 277 | } 278 | 279 | #pragma mark - PFWebViewToolBarDelegate 280 | 281 | - (void)webViewToolbarGoBack:(PFWebViewToolBar *)toolbar { 282 | if ([self.webView canGoBack]) { 283 | [UIView animateWithDuration:0.3f animations:^{ 284 | self.webMaskView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.0f]; 285 | self.maskLayer.frame = CGRectMake(0.0f, 0.0f, _readerWebView.frame.size.width, 0.0f); 286 | } completion:^(BOOL finished) { 287 | _readerWebView.userInteractionEnabled = NO; 288 | }]; 289 | [_readerWebView loadHTMLString:@"" baseURL:nil]; 290 | [self.webView goBack]; 291 | } 292 | } 293 | 294 | - (void)webViewToolbarGoForward:(PFWebViewToolBar *)toolbar { 295 | if ([self.webView canGoForward]) { 296 | [UIView animateWithDuration:0.3f animations:^{ 297 | self.webMaskView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.0f]; 298 | self.maskLayer.frame = CGRectMake(0.0f, 0.0f, _readerWebView.frame.size.width, 0.0f); 299 | } completion:^(BOOL finished) { 300 | _readerWebView.userInteractionEnabled = NO; 301 | }]; 302 | [_readerWebView loadHTMLString:@"" baseURL:nil]; 303 | [self.webView goForward]; 304 | } 305 | } 306 | 307 | - (void)webViewToolbarDidSwitchReaderMode:(PFWebViewToolBar *)toolbar { 308 | isReaderMode = !isReaderMode; 309 | if (isReaderMode) { 310 | [_webView evaluateJavaScript: 311 | @"var ReaderArticleFinderJS = new ReaderArticleFinder(document);" 312 | "var article = ReaderArticleFinderJS.findArticle(); article.element.outerHTML" completionHandler:^(id _Nullable object, NSError * _Nullable error) { 313 | if ([object isKindOfClass:[NSString class]] && isReaderMode) { 314 | [_webView evaluateJavaScript:@"ReaderArticleFinderJS.articleTitle()" completionHandler:^(id _Nullable object_in, NSError * _Nullable error) { 315 | readerArticleTitle = object_in; 316 | 317 | NSMutableString *mut_str = [readerHTMLString mutableCopy]; 318 | 319 | // Replace page title with article title 320 | [mut_str replaceOccurrencesOfString:@"Reader" withString:readerArticleTitle options:NSLiteralSearch range:NSMakeRange(0, 300)]; 321 | NSRange t = [mut_str rangeOfString:@"
"]; 322 | NSInteger location = t.location + t.length; 323 | 324 | NSString *t_object = [NSString stringWithFormat:@"
%@
",object]; 325 | [mut_str insertString:t_object atIndex:location]; 326 | 327 | [_readerWebView loadHTMLString:mut_str baseURL:self.url]; 328 | _readerWebView.alpha = 0.0f; 329 | 330 | [_webView evaluateJavaScript:@"ReaderArticleFinderJS.prepareToTransitionToReader();" completionHandler:^(id _Nullable object, NSError * _Nullable error) {}]; 331 | }]; 332 | } 333 | }]; 334 | } else { 335 | [UIView animateWithDuration:0.2f animations:^{ 336 | self.webMaskView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.0f]; 337 | self.maskLayer.frame = CGRectMake(0.0f, 0.0f, _readerWebView.frame.size.width, 0.0f); 338 | } completion:^(BOOL finished) { 339 | _readerWebView.userInteractionEnabled = NO; 340 | }]; 341 | } 342 | } 343 | 344 | - (void)webViewToolbarOpenInSafari:(PFWebViewToolBar *)toolbar { 345 | UIApplication *application = [UIApplication sharedApplication]; 346 | #ifndef __IPHONE_10_0 347 | #define __IPHONE_10_0 100000 348 | #endif 349 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 350 | if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) { 351 | [application openURL:self.webView.URL options:@{} completionHandler:nil]; 352 | } else { 353 | [application openURL:self.webView.URL]; 354 | } 355 | #else 356 | [application openURL:self.webView.URL]; 357 | #endif 358 | } 359 | 360 | - (void)webViewToolbarClose:(PFWebViewToolBar *)toolbar { 361 | if (self.navigationController) { 362 | [self.navigationController popViewControllerAnimated:YES]; 363 | } else { 364 | [self dismissViewControllerAnimated:YES completion:nil]; 365 | } 366 | } 367 | 368 | #pragma mark - WKWebViewNavigationDelegate Methods 369 | 370 | - (void)webView:(WKWebView *)webView didCommitNavigation:(null_unspecified WKNavigation *)navigation { 371 | if ([webView isEqual:self.readerWebView]) { 372 | return; 373 | } 374 | 375 | if (![self.webView.URL.absoluteString isEqualToString:@"about:blank"]) { 376 | // Cache current url after every frame entering if not blank page 377 | self.url = self.webView.URL; 378 | isReaderMode = NO; 379 | 380 | self.toolbar.readerModeBtn.selected = NO; 381 | 382 | // Set reader mode button enabled NO when begin navigation 383 | self.toolbar.readerModeBtn.enabled = NO; 384 | } 385 | } 386 | 387 | - (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation { 388 | if (webView == _webView) { 389 | // Set reader mode button status when navigation finished 390 | [webView evaluateJavaScript:@"var ReaderArticleFinderJS = new ReaderArticleFinder(document); ReaderArticleFinderJS.isReaderModeAvailable();" completionHandler:^(id _Nullable object, NSError * _Nullable error) { 391 | if ([object integerValue] == 1) { 392 | self.toolbar.readerModeBtn.enabled = YES; 393 | } else { 394 | self.toolbar.readerModeBtn.enabled = NO; 395 | } 396 | }]; 397 | } 398 | } 399 | 400 | // 拦截非 Http:// 和 Https:// 开头的请求,转成应用内跳转 401 | - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { 402 | if ([webView isEqual:self.readerWebView]) { 403 | decisionHandler(WKNavigationActionPolicyAllow); 404 | return; 405 | } 406 | 407 | if (![navigationAction.request.URL.absoluteString containsString:@"http://"] && ![navigationAction.request.URL.absoluteString containsString:@"https://"]) { 408 | 409 | UIApplication *application = [UIApplication sharedApplication]; 410 | #ifndef __IPHONE_10_0 411 | #define __IPHONE_10_0 100000 412 | #endif 413 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 414 | if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) { 415 | [application openURL:navigationAction.request.URL options:@{} completionHandler:nil]; 416 | } else { 417 | [application openURL:navigationAction.request.URL]; 418 | } 419 | #else 420 | [application openURL:navigationAction.request.URL]; 421 | #endif 422 | decisionHandler(WKNavigationActionPolicyCancel); 423 | } else { 424 | decisionHandler(WKNavigationActionPolicyAllow); 425 | } 426 | } 427 | 428 | - (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler { 429 | decisionHandler(WKNavigationResponsePolicyAllow); 430 | } 431 | 432 | - (void)userContentController:(WKUserContentController *)userContentController 433 | didReceiveScriptMessage:(WKScriptMessage *)message { 434 | _readerWebView.alpha = 1.0f; 435 | 436 | dispatch_async(dispatch_get_main_queue(), ^{ 437 | [UIView animateWithDuration:0.1f delay:0.2f options:UIViewAnimationOptionCurveEaseInOut animations:^{ 438 | self.webMaskView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.4f]; 439 | self.maskLayer.frame = CGRectMake(0.0f, 0.0f, _readerWebView.frame.size.width, _readerWebView.frame.size.height); 440 | } completion:^(BOOL finished) { 441 | _readerWebView.userInteractionEnabled = YES; 442 | }]; 443 | }); 444 | 445 | } 446 | 447 | @end 448 | -------------------------------------------------------------------------------- /Classes/PFWebViewNavigationHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFWebViewNavigationHeader.h 3 | // PFWebViewController 4 | // 5 | // Created by Cee on 9/19/16. 6 | // Copyright © 2016 Cee. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PFWebViewNavigationHeader : UIView 12 | 13 | - (id)initWithURL:(NSURL *)url; 14 | - (void)setURL:(NSURL *)url; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Classes/PFWebViewNavigationHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // PFWebViewNavigationHeader.m 3 | // PFWebViewController 4 | // 5 | // Created by Cee on 9/19/16. 6 | // Copyright © 2016 Cee. All rights reserved. 7 | // 8 | 9 | #import "PFWebViewNavigationHeader.h" 10 | #import 11 | 12 | #define SCREENWIDTH [UIScreen mainScreen].bounds.size.width 13 | #define SCREENHEIGHT [UIScreen mainScreen].bounds.size.height 14 | 15 | @interface PFWebViewNavigationHeader () 16 | @property (nonatomic, assign) CGFloat offset; 17 | @property (nonatomic, strong) UIView *bottomLine; 18 | @property (nonatomic, strong) UILabel *urlLabel; 19 | @end 20 | 21 | @implementation PFWebViewNavigationHeader 22 | 23 | - (id)initWithURL:(NSURL *)url { 24 | self.offset = SCREENWIDTH < SCREENHEIGHT ? 20.f : 0.f; 25 | self = [super initWithFrame:CGRectMake(0, 0, SCREENWIDTH, 20.5f + self.offset)]; 26 | if (self) { 27 | self.urlLabel.text = [url host]; 28 | [self setup]; 29 | } 30 | return self; 31 | } 32 | 33 | - (void)setURL:(NSURL *)url { 34 | self.urlLabel.text = [url host]; 35 | } 36 | 37 | - (void)setup { 38 | self.backgroundColor = [UIColor whiteColor]; 39 | [self addSubview:self.urlLabel]; 40 | [self addSubview:self.bottomLine]; 41 | } 42 | 43 | - (void)layoutSubviews { 44 | [super layoutSubviews]; 45 | self.offset = SCREENWIDTH < SCREENHEIGHT ? 20.f : 0.f; 46 | self.frame = CGRectMake(0, 0, SCREENWIDTH, 20.5f + self.offset); 47 | self.urlLabel.frame = CGRectMake(0, self.offset, SCREENWIDTH, 20); 48 | self.bottomLine.frame = CGRectMake(0, 20 + self.offset, SCREENWIDTH, .5f); 49 | } 50 | 51 | - (UILabel *)urlLabel { 52 | if (!_urlLabel) { 53 | _urlLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.offset, SCREENWIDTH, 20)]; 54 | _urlLabel.textAlignment = NSTextAlignmentCenter; 55 | _urlLabel.font = [UIFont systemFontOfSize:11]; 56 | _urlLabel.numberOfLines = 1; 57 | } 58 | return _urlLabel; 59 | } 60 | 61 | - (UIView *)bottomLine { 62 | if (!_bottomLine) { 63 | _bottomLine = [[UIView alloc] initWithFrame:CGRectMake(0, 20 + self.offset, SCREENWIDTH, .5f)]; 64 | _bottomLine.backgroundColor = [UIColor colorWithRed:234.f/255.f green:237.f/255.f blue:242.f/255.f alpha:1.f]; 65 | } 66 | return _bottomLine; 67 | } 68 | /* 69 | // Only override drawRect: if you perform custom drawing. 70 | // An empty implementation adversely affects performance during animation. 71 | - (void)drawRect:(CGRect)rect { 72 | // Drawing code 73 | } 74 | */ 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /Classes/PFWebViewToolBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFWebViewToolBar.h 3 | // PFWebViewController 4 | // 5 | // Created by Cee on 9/19/16. 6 | // Copyright © 2016 Cee. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class PFWebViewToolBar; 12 | 13 | @protocol PFWebViewToolBarDelegate 14 | 15 | - (void)webViewToolbarGoBack:(PFWebViewToolBar *)toolbar; 16 | - (void)webViewToolbarGoForward:(PFWebViewToolBar *)toolbar; 17 | - (void)webViewToolbarOpenInSafari:(PFWebViewToolBar *)toolbar; 18 | - (void)webViewToolbarClose:(PFWebViewToolBar *)toolbar; 19 | - (void)webViewToolbarDidSwitchReaderMode:(PFWebViewToolBar *)toolbar; 20 | 21 | @end 22 | 23 | @interface PFWebViewToolBar : UIView 24 | 25 | @property (weak, nonatomic) id delegate; 26 | 27 | @property (weak, nonatomic) IBOutlet UIButton *closeBtn; 28 | @property (weak, nonatomic) IBOutlet UIButton *backBtn; 29 | @property (weak, nonatomic) IBOutlet UIButton *forwardBtn; 30 | @property (weak, nonatomic) IBOutlet UIButton *openInSafariBtn; 31 | @property (weak, nonatomic) IBOutlet UIButton *readerModeBtn; 32 | 33 | - (void)setup; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Classes/PFWebViewToolBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // PFWebViewToolBar.m 3 | // PFWebViewController 4 | // 5 | // Created by Cee on 9/19/16. 6 | // Copyright © 2016 Cee. All rights reserved. 7 | // 8 | 9 | #import "PFWebViewToolBar.h" 10 | 11 | @implementation PFWebViewToolBar 12 | 13 | #pragma mark - Life cycle 14 | 15 | - (id)initWithFrame:(CGRect)frame { 16 | self = [super initWithFrame:frame]; 17 | if (self) { 18 | NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"PFWebViewController" ofType:@"bundle"]]; 19 | NSString *className = NSStringFromClass([self class]); 20 | self = [[bundle loadNibNamed:className owner:self options:nil] firstObject]; 21 | self.frame = frame; 22 | } 23 | return self; 24 | } 25 | 26 | - (void)setup { 27 | NSBundle *bundle = [NSBundle bundleForClass:[self class]]; 28 | NSURL *url = [bundle URLForResource:@"PFWebViewController" withExtension:@"bundle"]; 29 | NSBundle *imageBundle = [NSBundle bundleWithURL:url]; 30 | 31 | NSString *closeImagePath = [imageBundle pathForResource:@"icon_close" ofType:@"png"]; 32 | NSString *backImagePath = [imageBundle pathForResource:@"icon_back" ofType:@"png"]; 33 | NSString *backDisableImagePath = [imageBundle pathForResource:@"icon_back_disable" ofType:@"png"]; 34 | NSString *forwardImagePath = [imageBundle pathForResource:@"icon_next" ofType:@"png"]; 35 | NSString *forwardDisableImagePath = [imageBundle pathForResource:@"icon_next_disable" ofType:@"png"]; 36 | NSString *safariImagePath = [imageBundle pathForResource:@"icon_safari" ofType:@"png"]; 37 | NSString *readerModeImagePath = [imageBundle pathForResource:@"icon_read" ofType:@"png"]; 38 | NSString *readerModeDisableImagePath = [imageBundle pathForResource:@"icon_read_disable" ofType:@"png"]; 39 | NSString *readerModeSelectedImagePath = [imageBundle pathForResource:@"icon_read_back" ofType:@"png"]; 40 | 41 | [self.closeBtn setImage:[UIImage imageWithContentsOfFile:closeImagePath] 42 | forState:UIControlStateNormal]; 43 | [self.backBtn setImage:[UIImage imageWithContentsOfFile:backImagePath] 44 | forState:UIControlStateNormal]; 45 | [self.backBtn setImage:[UIImage imageWithContentsOfFile:backDisableImagePath] 46 | forState:UIControlStateDisabled]; 47 | [self.forwardBtn setImage:[UIImage imageWithContentsOfFile:forwardImagePath] 48 | forState:UIControlStateNormal]; 49 | [self.forwardBtn setImage:[UIImage imageWithContentsOfFile:forwardDisableImagePath] 50 | forState:UIControlStateDisabled]; 51 | [self.openInSafariBtn setImage:[UIImage imageWithContentsOfFile:safariImagePath] 52 | forState:UIControlStateNormal]; 53 | [self.readerModeBtn setImage:[UIImage imageWithContentsOfFile:readerModeImagePath] forState:UIControlStateNormal]; 54 | [self.readerModeBtn setImage:[UIImage imageWithContentsOfFile:readerModeDisableImagePath] forState:UIControlStateDisabled]; 55 | [self.readerModeBtn setImage:[UIImage imageWithContentsOfFile:readerModeSelectedImagePath] forState:UIControlStateSelected]; 56 | 57 | self.readerModeBtn.selected = NO; 58 | self.readerModeBtn.enabled = NO; 59 | 60 | self.backBtn.enabled = NO; 61 | self.forwardBtn.enabled = NO; 62 | } 63 | 64 | #pragma mark - Event response 65 | 66 | - (IBAction)close:(UIButton *)sender { 67 | if (self.delegate) { 68 | [self.delegate webViewToolbarClose:self]; 69 | } 70 | } 71 | 72 | - (IBAction)goBack:(UIButton *)sender { 73 | if (self.delegate) { 74 | [self.delegate webViewToolbarGoBack:self]; 75 | } 76 | } 77 | 78 | - (IBAction)goForward:(UIButton *)sender { 79 | if (self.delegate) { 80 | [self.delegate webViewToolbarGoForward:self]; 81 | } 82 | } 83 | 84 | - (IBAction)openInSafari:(UIButton *)sender { 85 | if (self.delegate) { 86 | [self.delegate webViewToolbarOpenInSafari:self]; 87 | } 88 | } 89 | 90 | - (IBAction)switchReaderMode:(id)sender { 91 | if ([self.delegate respondsToSelector:@selector(webViewToolbarDidSwitchReaderMode:)]) { 92 | [self.delegate webViewToolbarDidSwitchReaderMode:self]; 93 | self.readerModeBtn.selected = !self.readerModeBtn.selected; 94 | } 95 | } 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /Classes/PFWebViewToolBar.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 28 | 34 | 40 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Cee Cirno 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the"Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /PFWebViewController.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint PFWebViewController.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "PFWebViewController" 19 | s.version = "1.1.1" 20 | s.summary = "A light-weight webview controller using WKWebView. Support Safari-like reader mode." 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | s.description = <<-DESC 28 | A light-weight webview controller using WKWebView. It contains a progress bar and can estimate loading time. 29 | 30 | Support Safari-like reader mode. 31 | 32 | Easy use and less memory consuming than [RxWebViewController](https://github.com/Roxasora/RxWebViewController). 33 | DESC 34 | 35 | s.homepage = "https://github.com/PerfectFreeze/PFWebViewController" 36 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 37 | 38 | 39 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 40 | # 41 | # Licensing your code is important. See http://choosealicense.com for more info. 42 | # CocoaPods will detect a license file if there is a named LICENSE* 43 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 44 | # 45 | 46 | # s.license = "MIT (example)" 47 | s.license = { :type => "MIT", :file => "LICENSE" } 48 | 49 | 50 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 51 | # 52 | # Specify the authors of the library, with email addresses. Email addresses 53 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 54 | # accepts just a name if you'd rather not provide an email address. 55 | # 56 | # Specify a social_media_url where others can refer to, for example a twitter 57 | # profile URL. 58 | # 59 | 60 | s.author = { "Cee" => "cee@chu2byo.com" } 61 | # Or just: s.author = "Cee" 62 | # s.authors = { "Cee" => "cee@chu2byo.com" } 63 | s.social_media_url = "https://twitter.com/ceecirno" 64 | 65 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 66 | # 67 | # If this Pod runs only on iOS or OS X, then specify the platform and 68 | # the deployment target. You can optionally include the target after the platform. 69 | # 70 | 71 | # s.platform = :ios 72 | s.platform = :ios, "9.0" 73 | 74 | # When using multiple platforms 75 | # s.ios.deployment_target = "5.0" 76 | # s.osx.deployment_target = "10.7" 77 | # s.watchos.deployment_target = "2.0" 78 | # s.tvos.deployment_target = "9.0" 79 | 80 | 81 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 82 | # 83 | # Specify the location from where the source should be retrieved. 84 | # Supports git, hg, bzr, svn and HTTP. 85 | # 86 | 87 | s.source = { :git => "https://github.com/PerfectFreeze/PFWebViewController.git", :tag => "v#{s.version.to_s}" } 88 | 89 | 90 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 91 | # 92 | # CocoaPods is smart about how it includes source code. For source files 93 | # giving a folder will include any swift, h, m, mm, c & cpp files. 94 | # For header files it will include any header in the folder. 95 | # Not including the public_header_files will make all headers public. 96 | # 97 | 98 | s.source_files = "Classes", "Classes/**/*.{h,m}" 99 | s.exclude_files = "Classes/Exclude" 100 | 101 | # s.public_header_files = "Classes/**/*.h" 102 | 103 | 104 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 105 | # 106 | # A list of resources included with the Pod. These are copied into the 107 | # target bundle with a build phase script. Anything else will be cleaned. 108 | # You can preserve files from being cleaned, please don't preserve 109 | # non-essential files like tests, examples and documentation. 110 | # 111 | 112 | # s.resource = "icon.png" 113 | s.resources = "Classes/*.bundle" 114 | 115 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 116 | 117 | 118 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 119 | # 120 | # Link your library with frameworks, or libraries. Libraries do not include 121 | # the lib prefix of their name. 122 | # 123 | 124 | # s.framework = "SomeFramework" 125 | # s.frameworks = "SomeFramework", "AnotherFramework" 126 | 127 | # s.library = "iconv" 128 | # s.libraries = "iconv", "xml2" 129 | 130 | 131 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 132 | # 133 | # If your library depends on compiler flags you can set them in the xcconfig hash 134 | # where they will only apply to your library. If you depend on other Podspecs 135 | # you can include multiple dependencies to ensure it works. 136 | 137 | s.requires_arc = true 138 | 139 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 140 | # s.dependency "JSONKit", "~> 1.4" 141 | 142 | end 143 | -------------------------------------------------------------------------------- /PFWebViewController.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 921A45CA1D95870E0040BE3B /* PFWebViewController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 921A45C31D95870E0040BE3B /* PFWebViewController.framework */; }; 11 | 921A45CB1D95870E0040BE3B /* PFWebViewController.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 921A45C31D95870E0040BE3B /* PFWebViewController.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 12 | 921A45D01D9587300040BE3B /* PFWebViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 927D6EA51D9127420066D7BC /* PFWebViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; 13 | 921A45D11D9587440040BE3B /* PFWebViewNavigationHeader.h in Headers */ = {isa = PBXBuildFile; fileRef = 927D6EA71D9127420066D7BC /* PFWebViewNavigationHeader.h */; settings = {ATTRIBUTES = (Private, ); }; }; 14 | 921A45D21D9587440040BE3B /* PFWebViewToolBar.h in Headers */ = {isa = PBXBuildFile; fileRef = 927D6EA91D9127420066D7BC /* PFWebViewToolBar.h */; settings = {ATTRIBUTES = (Private, ); }; }; 15 | 921A45D31D95875A0040BE3B /* PFWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 927D6EA61D9127420066D7BC /* PFWebViewController.m */; }; 16 | 921A45D41D95875A0040BE3B /* PFWebViewNavigationHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = 927D6EA81D9127420066D7BC /* PFWebViewNavigationHeader.m */; }; 17 | 921A45D51D95875A0040BE3B /* PFWebViewToolBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 927D6EAA1D9127420066D7BC /* PFWebViewToolBar.m */; }; 18 | 921A45D61D9587600040BE3B /* PFWebViewController.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 927D6EA41D9127420066D7BC /* PFWebViewController.bundle */; }; 19 | 927D6EAC1D9127420066D7BC /* PFWebViewController.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 927D6EA41D9127420066D7BC /* PFWebViewController.bundle */; }; 20 | 927D6EAD1D9127420066D7BC /* PFWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 927D6EA61D9127420066D7BC /* PFWebViewController.m */; }; 21 | 927D6EAE1D9127420066D7BC /* PFWebViewNavigationHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = 927D6EA81D9127420066D7BC /* PFWebViewNavigationHeader.m */; }; 22 | 927D6EAF1D9127420066D7BC /* PFWebViewToolBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 927D6EAA1D9127420066D7BC /* PFWebViewToolBar.m */; }; 23 | 928771851D8FDAF400491C20 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 928771841D8FDAF400491C20 /* main.m */; }; 24 | 928771881D8FDAF400491C20 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 928771871D8FDAF400491C20 /* AppDelegate.m */; }; 25 | 9287718B1D8FDAF400491C20 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9287718A1D8FDAF400491C20 /* ViewController.m */; }; 26 | 9287718E1D8FDAF400491C20 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9287718C1D8FDAF400491C20 /* Main.storyboard */; }; 27 | 928771901D8FDAF400491C20 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9287718F1D8FDAF400491C20 /* Assets.xcassets */; }; 28 | 928771931D8FDAF400491C20 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 928771911D8FDAF400491C20 /* LaunchScreen.storyboard */; }; 29 | /* End PBXBuildFile section */ 30 | 31 | /* Begin PBXContainerItemProxy section */ 32 | 921A45C81D95870E0040BE3B /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = 928771781D8FDAF400491C20 /* Project object */; 35 | proxyType = 1; 36 | remoteGlobalIDString = 921A45C21D95870E0040BE3B; 37 | remoteInfo = PFWebViewControllerFramework; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXCopyFilesBuildPhase section */ 42 | 921A45CF1D95870E0040BE3B /* Embed Frameworks */ = { 43 | isa = PBXCopyFilesBuildPhase; 44 | buildActionMask = 2147483647; 45 | dstPath = ""; 46 | dstSubfolderSpec = 10; 47 | files = ( 48 | 921A45CB1D95870E0040BE3B /* PFWebViewController.framework in Embed Frameworks */, 49 | ); 50 | name = "Embed Frameworks"; 51 | runOnlyForDeploymentPostprocessing = 0; 52 | }; 53 | /* End PBXCopyFilesBuildPhase section */ 54 | 55 | /* Begin PBXFileReference section */ 56 | 50E32DDB1DACFA9D00906C27 /* libxml2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libxml2.tbd; path = usr/lib/libxml2.tbd; sourceTree = SDKROOT; }; 57 | 921A45C31D95870E0040BE3B /* PFWebViewController.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PFWebViewController.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | 921A45C51D95870E0040BE3B /* PFWebViewControllerFramework.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PFWebViewControllerFramework.h; sourceTree = ""; }; 59 | 921A45C61D95870E0040BE3B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 60 | 927D6EA41D9127420066D7BC /* PFWebViewController.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = PFWebViewController.bundle; sourceTree = ""; }; 61 | 927D6EA51D9127420066D7BC /* PFWebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFWebViewController.h; sourceTree = ""; }; 62 | 927D6EA61D9127420066D7BC /* PFWebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PFWebViewController.m; sourceTree = ""; }; 63 | 927D6EA71D9127420066D7BC /* PFWebViewNavigationHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFWebViewNavigationHeader.h; sourceTree = ""; }; 64 | 927D6EA81D9127420066D7BC /* PFWebViewNavigationHeader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PFWebViewNavigationHeader.m; sourceTree = ""; }; 65 | 927D6EA91D9127420066D7BC /* PFWebViewToolBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFWebViewToolBar.h; sourceTree = ""; }; 66 | 927D6EAA1D9127420066D7BC /* PFWebViewToolBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PFWebViewToolBar.m; sourceTree = ""; }; 67 | 927D6EB11D912A600066D7BC /* PFWebViewToolBar.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PFWebViewToolBar.xib; sourceTree = ""; }; 68 | 928771801D8FDAF400491C20 /* PFWebViewController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PFWebViewController.app; sourceTree = BUILT_PRODUCTS_DIR; }; 69 | 928771841D8FDAF400491C20 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 70 | 928771861D8FDAF400491C20 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 71 | 928771871D8FDAF400491C20 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 72 | 928771891D8FDAF400491C20 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 73 | 9287718A1D8FDAF400491C20 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 74 | 9287718D1D8FDAF400491C20 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 75 | 9287718F1D8FDAF400491C20 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 76 | 928771921D8FDAF400491C20 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 77 | 928771941D8FDAF400491C20 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 78 | /* End PBXFileReference section */ 79 | 80 | /* Begin PBXFrameworksBuildPhase section */ 81 | 921A45BF1D95870E0040BE3B /* Frameworks */ = { 82 | isa = PBXFrameworksBuildPhase; 83 | buildActionMask = 2147483647; 84 | files = ( 85 | ); 86 | runOnlyForDeploymentPostprocessing = 0; 87 | }; 88 | 9287717D1D8FDAF400491C20 /* Frameworks */ = { 89 | isa = PBXFrameworksBuildPhase; 90 | buildActionMask = 2147483647; 91 | files = ( 92 | 921A45CA1D95870E0040BE3B /* PFWebViewController.framework in Frameworks */, 93 | ); 94 | runOnlyForDeploymentPostprocessing = 0; 95 | }; 96 | /* End PBXFrameworksBuildPhase section */ 97 | 98 | /* Begin PBXGroup section */ 99 | 50E32DDA1DACFA9D00906C27 /* Frameworks */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | 50E32DDB1DACFA9D00906C27 /* libxml2.tbd */, 103 | ); 104 | name = Frameworks; 105 | sourceTree = ""; 106 | }; 107 | 921A45C41D95870E0040BE3B /* PFWebViewControllerFramework */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | 921A45C51D95870E0040BE3B /* PFWebViewControllerFramework.h */, 111 | 921A45C61D95870E0040BE3B /* Info.plist */, 112 | ); 113 | path = PFWebViewControllerFramework; 114 | sourceTree = ""; 115 | }; 116 | 927D6EA31D9127420066D7BC /* Classes */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | 927D6EA41D9127420066D7BC /* PFWebViewController.bundle */, 120 | 927D6EA51D9127420066D7BC /* PFWebViewController.h */, 121 | 927D6EA61D9127420066D7BC /* PFWebViewController.m */, 122 | 927D6EA71D9127420066D7BC /* PFWebViewNavigationHeader.h */, 123 | 927D6EA81D9127420066D7BC /* PFWebViewNavigationHeader.m */, 124 | 927D6EA91D9127420066D7BC /* PFWebViewToolBar.h */, 125 | 927D6EAA1D9127420066D7BC /* PFWebViewToolBar.m */, 126 | 927D6EB11D912A600066D7BC /* PFWebViewToolBar.xib */, 127 | ); 128 | path = Classes; 129 | sourceTree = ""; 130 | }; 131 | 928771771D8FDAF400491C20 = { 132 | isa = PBXGroup; 133 | children = ( 134 | 927D6EA31D9127420066D7BC /* Classes */, 135 | 928771821D8FDAF400491C20 /* PFWebViewController */, 136 | 921A45C41D95870E0040BE3B /* PFWebViewControllerFramework */, 137 | 928771811D8FDAF400491C20 /* Products */, 138 | 50E32DDA1DACFA9D00906C27 /* Frameworks */, 139 | ); 140 | sourceTree = ""; 141 | }; 142 | 928771811D8FDAF400491C20 /* Products */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 928771801D8FDAF400491C20 /* PFWebViewController.app */, 146 | 921A45C31D95870E0040BE3B /* PFWebViewController.framework */, 147 | ); 148 | name = Products; 149 | sourceTree = ""; 150 | }; 151 | 928771821D8FDAF400491C20 /* PFWebViewController */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | 928771861D8FDAF400491C20 /* AppDelegate.h */, 155 | 928771871D8FDAF400491C20 /* AppDelegate.m */, 156 | 928771891D8FDAF400491C20 /* ViewController.h */, 157 | 9287718A1D8FDAF400491C20 /* ViewController.m */, 158 | 9287718C1D8FDAF400491C20 /* Main.storyboard */, 159 | 9287718F1D8FDAF400491C20 /* Assets.xcassets */, 160 | 928771911D8FDAF400491C20 /* LaunchScreen.storyboard */, 161 | 928771941D8FDAF400491C20 /* Info.plist */, 162 | 928771831D8FDAF400491C20 /* Supporting Files */, 163 | ); 164 | path = PFWebViewController; 165 | sourceTree = ""; 166 | }; 167 | 928771831D8FDAF400491C20 /* Supporting Files */ = { 168 | isa = PBXGroup; 169 | children = ( 170 | 928771841D8FDAF400491C20 /* main.m */, 171 | ); 172 | name = "Supporting Files"; 173 | sourceTree = ""; 174 | }; 175 | /* End PBXGroup section */ 176 | 177 | /* Begin PBXHeadersBuildPhase section */ 178 | 921A45C01D95870E0040BE3B /* Headers */ = { 179 | isa = PBXHeadersBuildPhase; 180 | buildActionMask = 2147483647; 181 | files = ( 182 | 921A45D01D9587300040BE3B /* PFWebViewController.h in Headers */, 183 | 921A45D11D9587440040BE3B /* PFWebViewNavigationHeader.h in Headers */, 184 | 921A45D21D9587440040BE3B /* PFWebViewToolBar.h in Headers */, 185 | ); 186 | runOnlyForDeploymentPostprocessing = 0; 187 | }; 188 | /* End PBXHeadersBuildPhase section */ 189 | 190 | /* Begin PBXNativeTarget section */ 191 | 921A45C21D95870E0040BE3B /* PFWebViewControllerFramework */ = { 192 | isa = PBXNativeTarget; 193 | buildConfigurationList = 921A45CE1D95870E0040BE3B /* Build configuration list for PBXNativeTarget "PFWebViewControllerFramework" */; 194 | buildPhases = ( 195 | 921A45BE1D95870E0040BE3B /* Sources */, 196 | 921A45BF1D95870E0040BE3B /* Frameworks */, 197 | 921A45C01D95870E0040BE3B /* Headers */, 198 | 921A45C11D95870E0040BE3B /* Resources */, 199 | ); 200 | buildRules = ( 201 | ); 202 | dependencies = ( 203 | ); 204 | name = PFWebViewControllerFramework; 205 | productName = PFWebViewControllerFramework; 206 | productReference = 921A45C31D95870E0040BE3B /* PFWebViewController.framework */; 207 | productType = "com.apple.product-type.framework"; 208 | }; 209 | 9287717F1D8FDAF400491C20 /* PFWebViewController */ = { 210 | isa = PBXNativeTarget; 211 | buildConfigurationList = 928771971D8FDAF400491C20 /* Build configuration list for PBXNativeTarget "PFWebViewController" */; 212 | buildPhases = ( 213 | 9287717C1D8FDAF400491C20 /* Sources */, 214 | 9287717D1D8FDAF400491C20 /* Frameworks */, 215 | 9287717E1D8FDAF400491C20 /* Resources */, 216 | 921A45CF1D95870E0040BE3B /* Embed Frameworks */, 217 | ); 218 | buildRules = ( 219 | ); 220 | dependencies = ( 221 | 921A45C91D95870E0040BE3B /* PBXTargetDependency */, 222 | ); 223 | name = PFWebViewController; 224 | productName = PFWebViewController; 225 | productReference = 928771801D8FDAF400491C20 /* PFWebViewController.app */; 226 | productType = "com.apple.product-type.application"; 227 | }; 228 | /* End PBXNativeTarget section */ 229 | 230 | /* Begin PBXProject section */ 231 | 928771781D8FDAF400491C20 /* Project object */ = { 232 | isa = PBXProject; 233 | attributes = { 234 | KnownAssetTags = ( 235 | PFNavigationController, 236 | ); 237 | LastUpgradeCheck = 0800; 238 | ORGANIZATIONNAME = Cee; 239 | TargetAttributes = { 240 | 921A45C21D95870E0040BE3B = { 241 | CreatedOnToolsVersion = 8.0; 242 | ProvisioningStyle = Automatic; 243 | }; 244 | 9287717F1D8FDAF400491C20 = { 245 | CreatedOnToolsVersion = 8.0; 246 | DevelopmentTeam = Q8H99663FH; 247 | ProvisioningStyle = Automatic; 248 | }; 249 | }; 250 | }; 251 | buildConfigurationList = 9287717B1D8FDAF400491C20 /* Build configuration list for PBXProject "PFWebViewController" */; 252 | compatibilityVersion = "Xcode 3.2"; 253 | developmentRegion = English; 254 | hasScannedForEncodings = 0; 255 | knownRegions = ( 256 | en, 257 | Base, 258 | ); 259 | mainGroup = 928771771D8FDAF400491C20; 260 | productRefGroup = 928771811D8FDAF400491C20 /* Products */; 261 | projectDirPath = ""; 262 | projectRoot = ""; 263 | targets = ( 264 | 9287717F1D8FDAF400491C20 /* PFWebViewController */, 265 | 921A45C21D95870E0040BE3B /* PFWebViewControllerFramework */, 266 | ); 267 | }; 268 | /* End PBXProject section */ 269 | 270 | /* Begin PBXResourcesBuildPhase section */ 271 | 921A45C11D95870E0040BE3B /* Resources */ = { 272 | isa = PBXResourcesBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | 921A45D61D9587600040BE3B /* PFWebViewController.bundle in Resources */, 276 | ); 277 | runOnlyForDeploymentPostprocessing = 0; 278 | }; 279 | 9287717E1D8FDAF400491C20 /* Resources */ = { 280 | isa = PBXResourcesBuildPhase; 281 | buildActionMask = 2147483647; 282 | files = ( 283 | 928771931D8FDAF400491C20 /* LaunchScreen.storyboard in Resources */, 284 | 927D6EAC1D9127420066D7BC /* PFWebViewController.bundle in Resources */, 285 | 928771901D8FDAF400491C20 /* Assets.xcassets in Resources */, 286 | 9287718E1D8FDAF400491C20 /* Main.storyboard in Resources */, 287 | ); 288 | runOnlyForDeploymentPostprocessing = 0; 289 | }; 290 | /* End PBXResourcesBuildPhase section */ 291 | 292 | /* Begin PBXSourcesBuildPhase section */ 293 | 921A45BE1D95870E0040BE3B /* Sources */ = { 294 | isa = PBXSourcesBuildPhase; 295 | buildActionMask = 2147483647; 296 | files = ( 297 | 921A45D31D95875A0040BE3B /* PFWebViewController.m in Sources */, 298 | 921A45D41D95875A0040BE3B /* PFWebViewNavigationHeader.m in Sources */, 299 | 921A45D51D95875A0040BE3B /* PFWebViewToolBar.m in Sources */, 300 | ); 301 | runOnlyForDeploymentPostprocessing = 0; 302 | }; 303 | 9287717C1D8FDAF400491C20 /* Sources */ = { 304 | isa = PBXSourcesBuildPhase; 305 | buildActionMask = 2147483647; 306 | files = ( 307 | 9287718B1D8FDAF400491C20 /* ViewController.m in Sources */, 308 | 928771881D8FDAF400491C20 /* AppDelegate.m in Sources */, 309 | 927D6EAE1D9127420066D7BC /* PFWebViewNavigationHeader.m in Sources */, 310 | 927D6EAF1D9127420066D7BC /* PFWebViewToolBar.m in Sources */, 311 | 928771851D8FDAF400491C20 /* main.m in Sources */, 312 | 927D6EAD1D9127420066D7BC /* PFWebViewController.m in Sources */, 313 | ); 314 | runOnlyForDeploymentPostprocessing = 0; 315 | }; 316 | /* End PBXSourcesBuildPhase section */ 317 | 318 | /* Begin PBXTargetDependency section */ 319 | 921A45C91D95870E0040BE3B /* PBXTargetDependency */ = { 320 | isa = PBXTargetDependency; 321 | target = 921A45C21D95870E0040BE3B /* PFWebViewControllerFramework */; 322 | targetProxy = 921A45C81D95870E0040BE3B /* PBXContainerItemProxy */; 323 | }; 324 | /* End PBXTargetDependency section */ 325 | 326 | /* Begin PBXVariantGroup section */ 327 | 9287718C1D8FDAF400491C20 /* Main.storyboard */ = { 328 | isa = PBXVariantGroup; 329 | children = ( 330 | 9287718D1D8FDAF400491C20 /* Base */, 331 | ); 332 | name = Main.storyboard; 333 | sourceTree = ""; 334 | }; 335 | 928771911D8FDAF400491C20 /* LaunchScreen.storyboard */ = { 336 | isa = PBXVariantGroup; 337 | children = ( 338 | 928771921D8FDAF400491C20 /* Base */, 339 | ); 340 | name = LaunchScreen.storyboard; 341 | sourceTree = ""; 342 | }; 343 | /* End PBXVariantGroup section */ 344 | 345 | /* Begin XCBuildConfiguration section */ 346 | 921A45CC1D95870E0040BE3B /* Debug */ = { 347 | isa = XCBuildConfiguration; 348 | buildSettings = { 349 | CODE_SIGN_IDENTITY = ""; 350 | CURRENT_PROJECT_VERSION = 1; 351 | DEFINES_MODULE = YES; 352 | DEVELOPMENT_TEAM = ""; 353 | DYLIB_COMPATIBILITY_VERSION = 1; 354 | DYLIB_CURRENT_VERSION = 1; 355 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 356 | INFOPLIST_FILE = PFWebViewControllerFramework/Info.plist; 357 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 358 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 359 | OTHER_CFLAGS = "-fembed-bitcode"; 360 | PRODUCT_BUNDLE_IDENTIFIER = io.Cee.PFWebViewControllerFramework; 361 | PRODUCT_MODULE_NAME = PFWebViewController; 362 | PRODUCT_NAME = PFWebViewController; 363 | SKIP_INSTALL = YES; 364 | VERSIONING_SYSTEM = "apple-generic"; 365 | VERSION_INFO_PREFIX = ""; 366 | }; 367 | name = Debug; 368 | }; 369 | 921A45CD1D95870E0040BE3B /* Release */ = { 370 | isa = XCBuildConfiguration; 371 | buildSettings = { 372 | CODE_SIGN_IDENTITY = ""; 373 | CURRENT_PROJECT_VERSION = 1; 374 | DEFINES_MODULE = YES; 375 | DEVELOPMENT_TEAM = ""; 376 | DYLIB_COMPATIBILITY_VERSION = 1; 377 | DYLIB_CURRENT_VERSION = 1; 378 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 379 | INFOPLIST_FILE = PFWebViewControllerFramework/Info.plist; 380 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 381 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 382 | OTHER_CFLAGS = "-fembed-bitcode"; 383 | PRODUCT_BUNDLE_IDENTIFIER = io.Cee.PFWebViewControllerFramework; 384 | PRODUCT_MODULE_NAME = PFWebViewController; 385 | PRODUCT_NAME = PFWebViewController; 386 | SKIP_INSTALL = YES; 387 | VERSIONING_SYSTEM = "apple-generic"; 388 | VERSION_INFO_PREFIX = ""; 389 | }; 390 | name = Release; 391 | }; 392 | 928771951D8FDAF400491C20 /* Debug */ = { 393 | isa = XCBuildConfiguration; 394 | buildSettings = { 395 | ALWAYS_SEARCH_USER_PATHS = NO; 396 | CLANG_ANALYZER_NONNULL = YES; 397 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 398 | CLANG_CXX_LIBRARY = "libc++"; 399 | CLANG_ENABLE_MODULES = YES; 400 | CLANG_ENABLE_OBJC_ARC = YES; 401 | CLANG_WARN_BOOL_CONVERSION = YES; 402 | CLANG_WARN_CONSTANT_CONVERSION = YES; 403 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 404 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 405 | CLANG_WARN_EMPTY_BODY = YES; 406 | CLANG_WARN_ENUM_CONVERSION = YES; 407 | CLANG_WARN_INFINITE_RECURSION = YES; 408 | CLANG_WARN_INT_CONVERSION = YES; 409 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 410 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 411 | CLANG_WARN_UNREACHABLE_CODE = YES; 412 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 413 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 414 | COPY_PHASE_STRIP = NO; 415 | DEBUG_INFORMATION_FORMAT = dwarf; 416 | ENABLE_STRICT_OBJC_MSGSEND = YES; 417 | ENABLE_TESTABILITY = YES; 418 | GCC_C_LANGUAGE_STANDARD = gnu99; 419 | GCC_DYNAMIC_NO_PIC = NO; 420 | GCC_NO_COMMON_BLOCKS = YES; 421 | GCC_OPTIMIZATION_LEVEL = 0; 422 | GCC_PREPROCESSOR_DEFINITIONS = ( 423 | "DEBUG=1", 424 | "$(inherited)", 425 | ); 426 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 427 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 428 | GCC_WARN_UNDECLARED_SELECTOR = YES; 429 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 430 | GCC_WARN_UNUSED_FUNCTION = YES; 431 | GCC_WARN_UNUSED_VARIABLE = YES; 432 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 433 | MTL_ENABLE_DEBUG_INFO = YES; 434 | ONLY_ACTIVE_ARCH = YES; 435 | SDKROOT = iphoneos; 436 | TARGETED_DEVICE_FAMILY = "1,2"; 437 | }; 438 | name = Debug; 439 | }; 440 | 928771961D8FDAF400491C20 /* Release */ = { 441 | isa = XCBuildConfiguration; 442 | buildSettings = { 443 | ALWAYS_SEARCH_USER_PATHS = NO; 444 | CLANG_ANALYZER_NONNULL = YES; 445 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 446 | CLANG_CXX_LIBRARY = "libc++"; 447 | CLANG_ENABLE_MODULES = YES; 448 | CLANG_ENABLE_OBJC_ARC = YES; 449 | CLANG_WARN_BOOL_CONVERSION = YES; 450 | CLANG_WARN_CONSTANT_CONVERSION = YES; 451 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 452 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 453 | CLANG_WARN_EMPTY_BODY = YES; 454 | CLANG_WARN_ENUM_CONVERSION = YES; 455 | CLANG_WARN_INFINITE_RECURSION = YES; 456 | CLANG_WARN_INT_CONVERSION = YES; 457 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 458 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 459 | CLANG_WARN_UNREACHABLE_CODE = YES; 460 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 461 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 462 | COPY_PHASE_STRIP = NO; 463 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 464 | ENABLE_NS_ASSERTIONS = NO; 465 | ENABLE_STRICT_OBJC_MSGSEND = YES; 466 | GCC_C_LANGUAGE_STANDARD = gnu99; 467 | GCC_NO_COMMON_BLOCKS = YES; 468 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 469 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 470 | GCC_WARN_UNDECLARED_SELECTOR = YES; 471 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 472 | GCC_WARN_UNUSED_FUNCTION = YES; 473 | GCC_WARN_UNUSED_VARIABLE = YES; 474 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 475 | MTL_ENABLE_DEBUG_INFO = NO; 476 | SDKROOT = iphoneos; 477 | TARGETED_DEVICE_FAMILY = "1,2"; 478 | VALIDATE_PRODUCT = YES; 479 | }; 480 | name = Release; 481 | }; 482 | 928771981D8FDAF400491C20 /* Debug */ = { 483 | isa = XCBuildConfiguration; 484 | buildSettings = { 485 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 486 | DEVELOPMENT_TEAM = Q8H99663FH; 487 | INFOPLIST_FILE = PFWebViewController/Info.plist; 488 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 489 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 490 | PRODUCT_BUNDLE_IDENTIFIER = io.Cee.PFWebViewController; 491 | PRODUCT_NAME = "$(TARGET_NAME)"; 492 | VALID_ARCHS = "arm64 armv7 armv7s"; 493 | }; 494 | name = Debug; 495 | }; 496 | 928771991D8FDAF400491C20 /* Release */ = { 497 | isa = XCBuildConfiguration; 498 | buildSettings = { 499 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 500 | DEVELOPMENT_TEAM = Q8H99663FH; 501 | INFOPLIST_FILE = PFWebViewController/Info.plist; 502 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 503 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 504 | PRODUCT_BUNDLE_IDENTIFIER = io.Cee.PFWebViewController; 505 | PRODUCT_NAME = "$(TARGET_NAME)"; 506 | VALID_ARCHS = "arm64 armv7 armv7s"; 507 | }; 508 | name = Release; 509 | }; 510 | /* End XCBuildConfiguration section */ 511 | 512 | /* Begin XCConfigurationList section */ 513 | 921A45CE1D95870E0040BE3B /* Build configuration list for PBXNativeTarget "PFWebViewControllerFramework" */ = { 514 | isa = XCConfigurationList; 515 | buildConfigurations = ( 516 | 921A45CC1D95870E0040BE3B /* Debug */, 517 | 921A45CD1D95870E0040BE3B /* Release */, 518 | ); 519 | defaultConfigurationIsVisible = 0; 520 | defaultConfigurationName = Release; 521 | }; 522 | 9287717B1D8FDAF400491C20 /* Build configuration list for PBXProject "PFWebViewController" */ = { 523 | isa = XCConfigurationList; 524 | buildConfigurations = ( 525 | 928771951D8FDAF400491C20 /* Debug */, 526 | 928771961D8FDAF400491C20 /* Release */, 527 | ); 528 | defaultConfigurationIsVisible = 0; 529 | defaultConfigurationName = Release; 530 | }; 531 | 928771971D8FDAF400491C20 /* Build configuration list for PBXNativeTarget "PFWebViewController" */ = { 532 | isa = XCConfigurationList; 533 | buildConfigurations = ( 534 | 928771981D8FDAF400491C20 /* Debug */, 535 | 928771991D8FDAF400491C20 /* Release */, 536 | ); 537 | defaultConfigurationIsVisible = 0; 538 | defaultConfigurationName = Release; 539 | }; 540 | /* End XCConfigurationList section */ 541 | }; 542 | rootObject = 928771781D8FDAF400491C20 /* Project object */; 543 | } 544 | -------------------------------------------------------------------------------- /PFWebViewController.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PFWebViewController.xcodeproj/xcshareddata/xcschemes/PFWebViewControllerFramework.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /PFWebViewController/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // PFWebViewController 4 | // 5 | // Created by Cee on 9/19/16. 6 | // Copyright © 2016 Cee. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /PFWebViewController/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // PFWebViewController 4 | // 5 | // Created by Cee on 9/19/16. 6 | // Copyright © 2016 Cee. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /PFWebViewController/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /PFWebViewController/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /PFWebViewController/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /PFWebViewController/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /PFWebViewController/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSAppTransportSecurity 6 | 7 | NSAllowsArbitraryLoads 8 | 9 | 10 | CFBundleDevelopmentRegion 11 | en 12 | CFBundleExecutable 13 | $(EXECUTABLE_NAME) 14 | CFBundleIdentifier 15 | $(PRODUCT_BUNDLE_IDENTIFIER) 16 | CFBundleInfoDictionaryVersion 17 | 6.0 18 | CFBundleName 19 | $(PRODUCT_NAME) 20 | CFBundlePackageType 21 | APPL 22 | CFBundleShortVersionString 23 | 1.0 24 | CFBundleVersion 25 | 1 26 | LSRequiresIPhoneOS 27 | 28 | UILaunchStoryboardName 29 | LaunchScreen 30 | UIMainStoryboardFile 31 | Main 32 | UIRequiredDeviceCapabilities 33 | 34 | armv7 35 | 36 | UISupportedInterfaceOrientations 37 | 38 | UIInterfaceOrientationPortrait 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UISupportedInterfaceOrientations~ipad 43 | 44 | UIInterfaceOrientationPortrait 45 | UIInterfaceOrientationPortraitUpsideDown 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /PFWebViewController/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // PFWebViewController 4 | // 5 | // Created by Cee on 9/19/16. 6 | // Copyright © 2016 Cee. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /PFWebViewController/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // PFWebViewController 4 | // 5 | // Created by Cee on 9/19/16. 6 | // Copyright © 2016 Cee. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "PFWebViewController/PFWebViewController.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view, typically from a nib. 21 | } 22 | 23 | 24 | - (void)didReceiveMemoryWarning { 25 | [super didReceiveMemoryWarning]; 26 | // Dispose of any resources that can be recreated. 27 | } 28 | 29 | - (IBAction)btnPressed:(UIButton *)sender { 30 | PFWebViewController *webVC = [[PFWebViewController alloc] initWithURLString:@"http://3g.qq.com"]; 31 | [webVC setProgressBarColor:[UIColor redColor]]; // Default is black 32 | 33 | [self presentViewController:webVC animated:YES completion:nil]; 34 | // [self.navigationController pushViewController:webVC animated:YES]; 35 | } 36 | 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /PFWebViewController/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PFWebViewController 4 | // 5 | // Created by Cee on 9/19/16. 6 | // Copyright © 2016 Cee. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /PFWebViewControllerFramework/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /PFWebViewControllerFramework/PFWebViewControllerFramework.h: -------------------------------------------------------------------------------- 1 | // 2 | // PFWebViewControllerFramework.h 3 | // PFWebViewControllerFramework 4 | // 5 | // Created by Cee on 9/23/16. 6 | // Copyright © 2016 Cee. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for PFWebViewControllerFramework. 12 | FOUNDATION_EXPORT double PFWebViewControllerFrameworkVersionNumber; 13 | 14 | //! Project version string for PFWebViewControllerFramework. 15 | FOUNDATION_EXPORT const unsigned char PFWebViewControllerFrameworkVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PFWebViewController 2 | 3 | [![Version](https://img.shields.io/cocoapods/v/PFWebViewController.svg?style=flat)](http://cocoapods.org/pods/PFWebViewController) 4 | [![License](https://img.shields.io/cocoapods/l/PFWebViewController.svg?style=flat)](http://cocoapods.org/pods/PFWebViewController) 5 | [![Platform](https://img.shields.io/cocoapods/p/PFWebViewController.svg?style=flat)](http://cocoapods.org/pods/PFWebViewController) 6 | [![Downloads](https://img.shields.io/cocoapods/dt/PFWebViewController.svg?style=flat)](http://cocoapods.org/pods/PFWebViewController) 7 | 8 | ## Features 9 | 10 | - A light-weight webview controller using WKWebView. Only supports iOS 9 and above. 11 | 12 | - Easy use and less memory consuming than [RxWebViewController](https://github.com/Roxasora/RxWebViewController). 13 | 14 | - Support Safari-like reader mode. 15 | 16 | ## Screenshots 17 | 18 | ### Loading 19 | 20 | Loading 21 | 22 | ### Main Screen 23 | 24 | Main Screen 25 | Main Screen 26 | 27 | ### Reader Mode 28 | 29 | Reader Mode Off 30 | Reader Mode On 31 | 32 | ## Installation 33 | 34 | ### Using Carthage 35 | 36 | Add `PFWebViewController` to your `Cartfile`: 37 | 38 | ``` 39 | github "PerfectFreeze/PFWebViewController" 40 | ``` 41 | 42 | Run `carthage` to build this framework. 43 | 44 | Add `PFWebViewController.framework` to your Xcode project. 45 | 46 | ### Using CocoaPods 47 | 48 | Add `PFWebViewController` to your `Podfile`: 49 | 50 | ```ruby 51 | pod 'PFWebViewController', '~> 1.1.1' 52 | ``` 53 | 54 | Run `pod install` to install this framework. 55 | 56 | ### Manually 57 | 58 | Drag `Classes` folder to your project. 59 | 60 | ## Usage 61 | 62 | ```objective-c 63 | // Init with a string 64 | PFWebViewController *webVC = [[PFWebViewController alloc] initWithURLString:@"https://github.com"]; 65 | 66 | // Or with an URL 67 | NSURL *url = ...; 68 | PFWebViewController *webVC = [[PFWebViewController alloc] initWithURL:url]; 69 | 70 | // Optional: Set Progressbar's Color, default is black 71 | [webVC setProgressBarColor:[UIColor redColor]]; 72 | 73 | // Present in a single view 74 | [self presentViewController:webVC animated:YES completion:nil]; 75 | 76 | // Or push in a navigationController 77 | [self.navigationController pushViewController:webVC animated:YES]; 78 | ``` 79 | ## Further Reading 80 | 81 | - [How to implement Safari-like reader mode in PFWebViewController](http://sergiochan.xyz/2016/10/21/%E5%A6%82%E4%BD%95%E5%9C%A8-WKWebView-%E4%B8%AD%E5%AE%9E%E7%8E%B0-Safari-%E5%8E%9F%E7%94%9F%E7%9A%84%E9%98%85%E8%AF%BB%E6%A8%A1%E5%BC%8F/) 82 | 83 | ## License 84 | 85 | This project is released under the terms and conditions of the [MIT license](https://opensource.org/licenses/MIT). See [LICENSE](LICENSE) for details. 86 | -------------------------------------------------------------------------------- /Screenshots/GitHub_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Screenshots/GitHub_1.png -------------------------------------------------------------------------------- /Screenshots/GitHub_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Screenshots/GitHub_2.png -------------------------------------------------------------------------------- /Screenshots/Loading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Screenshots/Loading.png -------------------------------------------------------------------------------- /Screenshots/Reader_Mode_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Screenshots/Reader_Mode_1.png -------------------------------------------------------------------------------- /Screenshots/Reader_Mode_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFWebViewController/fbbb2416ef3a402a59b77ae863e223a977766cd5/Screenshots/Reader_Mode_2.png --------------------------------------------------------------------------------