You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2015/04/07 08:17:48 UTC
cordova-plugin-inappbrowser git commit: CB-7689 Adds insertCSS
support for windows platform
Repository: cordova-plugin-inappbrowser
Updated Branches:
refs/heads/master dfd099958 -> e2865db2e
CB-7689 Adds insertCSS support for windows platform
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/e2865db2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/e2865db2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/e2865db2
Branch: refs/heads/master
Commit: e2865db2eae80a2ab37e951856a39540f6534e16
Parents: dfd0999
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Wed Apr 1 16:57:58 2015 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Tue Apr 7 09:17:09 2015 +0300
----------------------------------------------------------------------
README.md | 1 +
src/windows/InAppBrowserProxy.js | 43 ++++++++++++++++++++++++++++++++++-
2 files changed, 43 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/e2865db2/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 1a7c2df..31a3c72 100644
--- a/README.md
+++ b/README.md
@@ -377,6 +377,7 @@ Due to [MSDN docs](https://msdn.microsoft.com/en-us/library/windows.ui.xaml.cont
- Amazon Fire OS
- Android
- iOS
+- Windows
### Quick Example
http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/e2865db2/src/windows/InAppBrowserProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/InAppBrowserProxy.js b/src/windows/InAppBrowserProxy.js
index cee0de9..817516e 100644
--- a/src/windows/InAppBrowserProxy.js
+++ b/src/windows/InAppBrowserProxy.js
@@ -213,7 +213,7 @@ var IAB = {
IAB.close(win);
}, 0);
});
-
+
if (!isWebViewAvailable) {
// iframe navigation is not yet supported
backButton.disabled = true;
@@ -277,9 +277,50 @@ var IAB = {
});
});
}
+ },
+
+ injectStyleCode: function (win, fail, args) {
+ var code = args[0],
+ hasCallback = args[1];
+
+ if (isWebViewAvailable && browserWrap && popup) {
+ injectCSS(popup, code, hasCallback && win);
+ }
+ },
+
+ injectStyleFile: function (win, fail, args) {
+ var filePath = args[0],
+ hasCallback = args[1];
+
+ filePath = filePath && urlutil.makeAbsolute(filePath);
+
+ if (isWebViewAvailable && browserWrap && popup) {
+ var uri = new Windows.Foundation.Uri(filePath);
+ Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).then(function (file) {
+ return Windows.Storage.FileIO.readTextAsync(file);
+ }).done(function (code) {
+ injectCSS(popup, code, hasCallback && win);
+ }, function () {
+ // no-op, just catch an error
+ });
+ }
}
};
+function injectCSS (webView, cssCode, callback) {
+ // This will automatically escape all thing that we need (quotes, slashes, etc.)
+ var escapedCode = JSON.stringify(cssCode);
+ var evalWrapper = "(function(d){var c=d.createElement('style');c.innerHTML=%s;d.head.appendChild(c);})(document)"
+ .replace('%s', escapedCode);
+
+ var op = webView.invokeScriptAsync("eval", evalWrapper);
+ op.oncomplete = function() {
+ callback && callback([]);
+ };
+ op.onerror = function () { };
+ op.start();
+}
+
module.exports = IAB;
require("cordova/exec/proxy").add("InAppBrowser", module.exports);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org