diff options
| author | Kumar Priyansh <[email protected]> | 2019-01-19 12:37:14 +0530 |
|---|---|---|
| committer | Kumar Priyansh <[email protected]> | 2019-01-19 12:37:14 +0530 |
| commit | dcdfc94cb39dfe2c39925a0145ffa45e2d061c30 (patch) | |
| tree | 4f6379d955555b298c0e7b83a67e264240ee5614 /www/wk-plugin.js | |
| parent | 76f7b3678d3f1ff99c3935a774d420453b0c3cb9 (diff) | |
| download | WeatherApp-dcdfc94cb39dfe2c39925a0145ffa45e2d061c30.tar.xz WeatherApp-dcdfc94cb39dfe2c39925a0145ffa45e2d061c30.zip | |
Initial Upload via GIT
Diffstat (limited to 'www/wk-plugin.js')
| -rw-r--r-- | www/wk-plugin.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/www/wk-plugin.js b/www/wk-plugin.js new file mode 100644 index 0000000..336ab8b --- /dev/null +++ b/www/wk-plugin.js @@ -0,0 +1,51 @@ + +(function _wk_plugin() { + // Check if we are running in WKWebView + if (!window.webkit || !window.webkit.messageHandlers) { + return; + } + + // Initialize Ionic + window.Ionic = window.Ionic || {}; + + function normalizeURL(url) { + console.warn('normalizeURL is deprecated, use window.Ionic.WebView.convertFileSrc'); + return window.Ionic.WebView.convertFileSrc(url); + } + if (typeof window.wkRewriteURL === 'undefined') { + window.wkRewriteURL = function (url) { + console.warn('wkRewriteURL is deprecated, use window.Ionic.WebView.convertFileSrc instead'); + return window.Ionic.WebView.convertFileSrc(url); + } + } + window.Ionic.normalizeURL = normalizeURL; + + var stopScrollHandler = window.webkit.messageHandlers.stopScroll; + if (!stopScrollHandler) { + console.error('Can not find stopScroll handler'); + return; + } + + var stopScrollFunc = null; + var stopScroll = { + stop: function stop(callback) { + if (!stopScrollFunc) { + stopScrollFunc = callback; + stopScrollHandler.postMessage(''); + } + }, + fire: function fire() { + stopScrollFunc && stopScrollFunc(); + stopScrollFunc = null; + }, + cancel: function cancel() { + stopScrollFunc = null; + } + }; + + window.Ionic.StopScroll = stopScroll; + // deprecated + window.IonicStopScroll = stopScroll; + + console.debug("Ionic Stop Scroll injected!"); +})(); |
