Permalink
Browse files

Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/cord…

  • Loading branch information...
2 parents c9f310f + 832eb92 commit 8186a04590e8bcc144a5cd1a224cb504502f4704 @purplecabbage purplecabbage committed Nov 30, 2012
@@ -22,7 +22,7 @@
module.exports = {
id: "playbook",
initialize:function() {},
- objects: {
+ clobbers: {
DirectoryReader:{
path: 'cordova/plugin/air/DirectoryReader'
},
@@ -40,6 +40,6 @@ module.exports = {
},
stop: function (args, win, fail) {
window.removeEventListener("deviceorientation", callback);
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
+ return { "status" : cordova.callbackStatus.OK, "message" : "removed" };
}
};
@@ -20,15 +20,52 @@
*/
var exec = require('cordova/exec');
+
+function InAppBrowser()
+{
+ var _channel = require('cordova/channel');
+ this.channels = {
+ 'loadstart': _channel.create('loadstart'),
+ 'loadstop' : _channel.create('loadstop'),
+ 'exit' : _channel.create('exit')
+ };
+}
-var InAppBrowser = {
- open : function(strUrl, strWindowName, strWindowFeatures) {
- exec(null, null, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
- return InAppBrowser;
- },
- close : function() {
- exec(null, null, "InAppBrowser", "close", []);
+InAppBrowser.prototype._eventHandler = function(event)
+{
+ if (event.type in this.channels) {
+ this.channels[event.type].fire(event);
}
-};
+}
+
+InAppBrowser.open = function(strUrl, strWindowName, strWindowFeatures)
+{
+ var iab = new InAppBrowser();
+ var cb = function(eventname) {
+ iab._eventHandler(eventname);
+ }
+ exec(cb, null, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
+ return iab;
+}
+
+InAppBrowser.prototype.close = function(eventname, f)
+{
+ exec(null, null, "InAppBrowser", "close", []);
+}
+
+InAppBrowser.prototype.addEventListener = function(eventname, f)
+{
+ if (eventname in this.channels) {
+ this.channels[eventname].subscribe(f);
+ }
+}
+
+InAppBrowser.prototype.removeEventListener = function(eventname, f)
+{
+ if (eventname in this.channels) {
+ this.channels[eventname].unsubscribe(f);
+ }
+}
module.exports = InAppBrowser.open;
+
View
@@ -19,16 +19,72 @@
*
*/
+var service=require('cordova/plugin/webos/service'),
+ cordova = require('cordova');
+
module.exports = {
id: "webos",
initialize: function() {
if (window.PalmSystem) {
window.PalmSystem.stageReady();
}
- window.Mojo = window.Mojo || {};
- window.Mojo.stageActivated = function() {
- console.error("stageActivated");
- };
+
+ var Mojo = window.Mojo || {};
+
+ // wait for deviceready before listening and firing document events
+ document.addEventListener("deviceready", function () {
+
+ // LunaSysMgr calls this when the windows is maximized or opened.
+ window.Mojo.stageActivated = function() {
+ console.log("stageActivated");
+ cordova.fireDocumentEvent("resume");
+ };
+ // LunaSysMgr calls this when the windows is minimized or closed.
+ window.Mojo.stageDeactivated = function() {
+ console.log("stageDeactivated");
+ cordova.fireDocumentEvent("pause");
+ };
+ // LunaSysMgr calls this when a KeepAlive app's window is hidden
+ window.Mojo.hide = function() {
+ console.log("hide");
+ };
+ // LunaSysMgr calls this when a KeepAlive app's window is shown
+ window.Mojo.show = function() {
+ console.log("show");
+ };
+
+ // LunaSysMgr calls this whenever an app is "launched;"
+ window.Mojo.relaunch = function() {
+ // need to return true to tell sysmgr the relaunch succeeded.
+ // otherwise, it'll try to focus the app, which will focus the first
+ // opened window of an app with multiple windows.
+ console.log("relaunch");
+ return true;
+ };
+
+ // start to listen for network connection changes
+ service.Request('palm://com.palm.connectionmanager', {
+ method: 'getstatus',
+ parameters: { subscribe: true },
+ onSuccess: function (result) {
+ console.log("subscribe:result:"+JSON.stringify(result));
+
+ if (!result.isInternetConnectionAvailable) {
+ if (navigator.onLine) {
+ console.log("Firing event:offline");
+ cordova.fireDocumentEvent("offline");
+ }
+ } else {
+ console.log("Firing event:online");
+ cordova.fireDocumentEvent("online");
+ }
+ },
+ onFailure: function(e) {
+ console.error("subscribe:error");
+ }
+ });
+
+ });
},
clobbers: {
requestFileSystem:{
@@ -19,7 +19,8 @@
*
*/
-var service=require('cordova/plugin/webos/service');
+var service=require('cordova/plugin/webos/service'),
+ Connection = require('cordova/plugin/Connection');
module.exports = {
/**
@@ -39,9 +40,9 @@ module.exports = {
console.log("result:"+JSON.stringify(result));
var info={};
- if (!result.isInternetConnectionAvailable) { info.type="Connection.NONE"; }
- if (result.wifi.onInternet) { info.type="Connection.WIFI"; }
- if (result.wan.state==="connected") { info.type="Connection.CELL_2G"; }
+ if (!result.isInternetConnectionAvailable) { info.type=Connection.NONE; }
+ if (result.wifi.onInternet) { info.type=Connection.WIFI; }
+ if (result.wan.state==="connected") { info.type=Connection.CELL_2G; }
successCallback(info.type);
},
Oops, something went wrong.

0 comments on commit 8186a04

Please sign in to comment.