cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brianler...@apache.org
Subject js commit: first pass at adding browser as a platform
Date Tue, 10 Dec 2013 01:35:49 GMT
Updated Branches:
  refs/heads/master 17d33054b -> c320378b4


first pass at adding browser as a platform


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

Branch: refs/heads/master
Commit: c320378b484a172a02d3ee26634bcc584f43b939
Parents: 17d3305
Author: brianleroux <b@brian.io>
Authored: Mon Dec 9 15:18:35 2013 +1000
Committer: brianleroux <b@brian.io>
Committed: Mon Dec 9 15:18:35 2013 +1000

----------------------------------------------------------------------
 Gruntfile.js            |  3 ++-
 lib/browser/exec.js     | 48 ++++++++++++++++++++++++++++++++++++++++++
 lib/browser/platform.js | 50 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c320378b/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index 3fb4d32..cd86689 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -34,7 +34,8 @@ module.exports = function(grunt) {
           "windows8": { useWindowsLineEndings: true },
           "windowsphone": { useWindowsLineEndings: true },
           "firefoxos": {},
-          "ubuntu": {}
+          "ubuntu": {},
+          "browser": {}
         },
         clean: ['pkg'],
         jshint: {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c320378b/lib/browser/exec.js
----------------------------------------------------------------------
diff --git a/lib/browser/exec.js b/lib/browser/exec.js
new file mode 100644
index 0000000..130edb9
--- /dev/null
+++ b/lib/browser/exec.js
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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');
+var execProxy = require('cordova/exec/proxy');
+
+module.exports = function(success, fail, service, action, args) {
+    
+    var proxy = execProxy.get(service, action);
+
+    if (proxy) {
+        var callbackId = service + cordova.callbackId++;
+
+        if (typeof success == "function" || typeof fail == "function") {
+            cordova.callbacks[callbackId] = {success:success, fail:fail};
+        }
+
+        try {
+            proxy(success, fail, args);
+        }
+        catch(e) {
+            // TODO throw maybe?
+            var msg = "Exception calling :: " + service + " :: " + action  + " ::exception="
+ e;
+            console.log(msg);
+        }
+    }
+    else {
+        fail && fail("Missing Command Error");
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c320378b/lib/browser/platform.js
----------------------------------------------------------------------
diff --git a/lib/browser/platform.js b/lib/browser/platform.js
new file mode 100644
index 0000000..fb30eea
--- /dev/null
+++ b/lib/browser/platform.js
@@ -0,0 +1,50 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+module.exports = {
+    id: 'browser',
+    cordovaVersion: '3.4.0',
+
+    bootstrap: function() {
+        
+        var moduleMapper = require('cordova/modulemapper');
+        var channel = require('cordova/channel');
+
+        moduleMapper.clobbers('cordova/exec/proxy', 'cordova.commandProxy');
+       
+        channel.onPluginsReady.subscribe(function () {
+            channel.onNativeReady.fire();
+        });
+
+        // FIXME is this the right place to clobber pause/resume? I am guessing not
+        // FIXME pause/resume should be deprecated IN CORDOVA for pagevisiblity api
+        document.addEventListener('webkitvisibilitychange', function() {
+            if (document.webkitHidden) {
+                channel.onPause.fire();
+            }
+            else {
+                channel.onResume.fire();
+            }
+        }, false);
+
+    // End of bootstrap
+    }
+};


Mime
View raw message