You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/04/10 00:43:08 UTC
[4/5] git commit: Added back button overriding (should kill CB-459)
and proper firing of events back into webview using cordova-js approach
Added back button overriding (should kill CB-459) and proper firing of events back into webview using cordova-js approach
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/d4a05724
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/d4a05724
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/d4a05724
Branch: refs/heads/master
Commit: d4a057245a1e0fe85c7a9cb05cdaccf854cbcd98
Parents: 7ded942
Author: filmaj <ma...@gmail.com>
Authored: Sun Apr 8 19:49:57 2012 -0700
Committer: filmaj <ma...@gmail.com>
Committed: Sun Apr 8 19:49:57 2012 -0700
----------------------------------------------------------------------
lib/wp7/platform.js | 17 +++++++++++++++--
lib/wp7/plugin/wp7/CordovaCommandResult.js | 2 +-
2 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/d4a05724/lib/wp7/platform.js
----------------------------------------------------------------------
diff --git a/lib/wp7/platform.js b/lib/wp7/platform.js
index fd511ab..ff61830 100644
--- a/lib/wp7/platform.js
+++ b/lib/wp7/platform.js
@@ -1,4 +1,5 @@
-
+var cordova = require('cordova'),
+ exec = require('cordova/exec');
module.exports = {
id: "wp7",
@@ -207,7 +208,19 @@ if(!window.localStorage)
})();};
-
+ // INject a lsitener for the backbutton, and tell native to override the flag (true/false) when we have 1 or more, or 0, listeners
+ var backButtonChannel = cordova.addDocumentEventHandler('backbutton', {
+ onSubscribe:function() {
+ if (this.numHandlers === 1) {
+ exec(null, null, "CoreEvents", "overridebackbutton", [true]);
+ }
+ },
+ onUnsubscribe:function() {
+ if (this.numHandlers === 0) {
+ exec(null, null, "CoreEvents", "overridebackbutton", [false]);
+ }
+ }
+ });
},
objects: {
CordovaCommandResult: {
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/d4a05724/lib/wp7/plugin/wp7/CordovaCommandResult.js
----------------------------------------------------------------------
diff --git a/lib/wp7/plugin/wp7/CordovaCommandResult.js b/lib/wp7/plugin/wp7/CordovaCommandResult.js
index e166258..9b7f390 100644
--- a/lib/wp7/plugin/wp7/CordovaCommandResult.js
+++ b/lib/wp7/plugin/wp7/CordovaCommandResult.js
@@ -6,7 +6,7 @@ var channel = require('cordova/channel');
module.exports = function(status,callbackId,args,cast) {
if(status === "backbutton") {
- cordova.fireEvent(document,"backbutton");
+ cordova.fireDocumentEvent("backbutton");
return "true";
}
else if(status === "resume") {