cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtan...@apache.org
Subject js commit: BlackBerry 10 InAppBrowser support
Date Wed, 09 Jan 2013 17:15:28 GMT
Updated Branches:
  refs/heads/master 05f19ce16 -> 745314e3a


BlackBerry 10 InAppBrowser support

- added common InAppBrowser to qnx platform
- created InAppBrowser qnx plugin
- updated qnx manager to route to InAppBrowser plugin
- exported the original window.open in the common InAppBrowser plugin
- updated .jshintrc to know about the webworks global to interface with
  our custom plugin.


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/745314e3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/745314e3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/745314e3

Branch: refs/heads/master
Commit: 745314e3a3f9f81a1d8652b9774c40d1fb01ba79
Parents: 05f19ce
Author: Gord Tanner <gtanner@gmail.com>
Authored: Tue Jan 8 01:05:32 2013 -0500
Committer: Gord Tanner <gtanner@gmail.com>
Committed: Wed Jan 9 12:12:15 2013 -0500

----------------------------------------------------------------------
 .jshintrc                                 |    2 +-
 lib/blackberry/plugin/qnx/InAppBrowser.js |   77 ++++++++++++++++++++++++
 lib/blackberry/plugin/qnx/manager.js      |    1 +
 lib/blackberry/plugin/qnx/platform.js     |    5 ++
 lib/common/plugin/InAppBrowser.js         |    5 +-
 5 files changed, 88 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/745314e3/.jshintrc
----------------------------------------------------------------------
diff --git a/.jshintrc b/.jshintrc
index 368b58a..076a30e 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -28,7 +28,7 @@
   "dojo": false,
 
   // Custom predefined globals.
-  "predef": ["jasmine", "blackberry", "define", "alert", "prompt", "org", "deviceapis", "Osp",
"_cordovaExec", "WinJS", "Windows", "MSApp", "PalmSystem", "PalmServiceBridge", "Acceleration"],
+  "predef": ["jasmine", "blackberry", "define", "alert", "prompt", "org", "deviceapis", "Osp",
"_cordovaExec", "WinJS", "Windows", "MSApp", "PalmSystem", "PalmServiceBridge", "Acceleration",
"webworks"],
 
 
   // Development

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/745314e3/lib/blackberry/plugin/qnx/InAppBrowser.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/InAppBrowser.js b/lib/blackberry/plugin/qnx/InAppBrowser.js
new file mode 100644
index 0000000..0280fe0
--- /dev/null
+++ b/lib/blackberry/plugin/qnx/InAppBrowser.js
@@ -0,0 +1,77 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var cordova = require('cordova'),
+    core = require('cordova/plugin/InAppBrowser');
+
+var navigate = {
+    "_blank": function (url, whitelisted) {
+        core._orig.apply(null, [url, "_blank"]);
+    },
+
+    "_self": function (url, whitelisted) {
+        if (whitelisted) {
+            window.location.href = url;
+        }
+        else {
+            core._orig.apply(null, [url, "_blank"]);
+        }
+    },
+
+    "_system": function (url, whitelisted) {
+        blackberry.invoke.invoke({
+            target: "sys.browser",
+            uri: url
+        }, function () {}, function () {});
+    }
+};
+
+
+module.exports = {
+    open: function (args, win, fail) {
+        var url = args[0],
+            target = args[1] || '_self',
+            a = document.createElement('a');
+
+        //Make all URLs absolute
+        a.href = url;
+        url = a.href;
+
+        switch (target) {
+            case '_self':
+            case '_system':
+            case '_blank':
+                break;
+            default:
+                target = '_blank';
+                break;
+        }
+
+        webworks.exec(function (whitelisted) {
+            navigate[target](url, whitelisted);
+        }, fail, "org.apache.cordova", "isWhitelisted", [url], true);
+
+        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "" };
+    },
+    close: function (args, win, fail) {
+        return { "status" : cordova.callbackStatus.OK, "message" : "" };
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/745314e3/lib/blackberry/plugin/qnx/manager.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/manager.js b/lib/blackberry/plugin/qnx/manager.js
index ccbefce..36244f9 100644
--- a/lib/blackberry/plugin/qnx/manager.js
+++ b/lib/blackberry/plugin/qnx/manager.js
@@ -32,6 +32,7 @@ var cordova = require('cordova'),
         'Notification' : require('cordova/plugin/webworks/notification'),
         'Media': require('cordova/plugin/webworks/media'),
         'File' : require('cordova/plugin/qnx/file'),
+        'InAppBrowser' : require('cordova/plugin/qnx/InAppBrowser'),
         'FileTransfer': require('cordova/plugin/qnx/fileTransfer')
     };
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/745314e3/lib/blackberry/plugin/qnx/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/platform.js b/lib/blackberry/plugin/qnx/platform.js
index 753e9dc..50ded05 100644
--- a/lib/blackberry/plugin/qnx/platform.js
+++ b/lib/blackberry/plugin/qnx/platform.js
@@ -41,6 +41,11 @@ module.exports = {
             });
         });
     },
+    clobbers: {
+        open: {
+            path: "cordova/plugin/InAppBrowser"
+        }
+    },
     merges: {
         navigator: {
             children: {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/745314e3/lib/common/plugin/InAppBrowser.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/InAppBrowser.js b/lib/common/plugin/InAppBrowser.js
index 9086b82..9b8bee1 100644
--- a/lib/common/plugin/InAppBrowser.js
+++ b/lib/common/plugin/InAppBrowser.js
@@ -58,4 +58,7 @@ module.exports = function(strUrl, strWindowName, strWindowFeatures) {
     };
     exec(cb, null, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
     return iab;
-};
\ No newline at end of file
+};
+
+//Export the original open so it can be used if needed
+module.exports._orig = window.open;


Mime
View raw message