incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject js commit: javascript fixes for allowing exceptions in custom backbutton handlers (required to close the app from back-button)
Date Wed, 05 Sep 2012 18:09:41 GMT
Updated Branches:
  refs/heads/master 2aa46aa0e -> 4a313d033


javascript fixes for allowing exceptions in custom backbutton handlers (required to close
the app from back-button)


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/4a313d03
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/4a313d03
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/4a313d03

Branch: refs/heads/master
Commit: 4a313d033d35dbccd001c4ec5d150a556f4da225
Parents: 2aa46aa
Author: viras <viras@users.sourceforge.net>
Authored: Wed Sep 5 19:53:41 2012 +0200
Committer: viras <viras@users.sourceforge.net>
Committed: Wed Sep 5 19:53:41 2012 +0200

----------------------------------------------------------------------
 lib/cordova.js                             |   14 ++++++++++----
 lib/wp7/plugin/wp7/CordovaCommandResult.js |    3 ++-
 2 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/4a313d03/lib/cordova.js
----------------------------------------------------------------------
diff --git a/lib/cordova.js b/lib/cordova.js
index ea5f7cd..e076773 100644
--- a/lib/cordova.js
+++ b/lib/cordova.js
@@ -115,13 +115,19 @@ var cordova = {
     },
     /**
      * Method to fire event from native code
+     * bNoDetach is required for events which cause an exception which needs to be caught
in native code     
      */
-    fireDocumentEvent: function(type, data) {
+    fireDocumentEvent: function(type, data, bNoDetach) {
         var evt = createEvent(type, data);
         if (typeof documentEventHandlers[type] != 'undefined') {
-            setTimeout(function() {
-                documentEventHandlers[type].fire(evt);
-            }, 0);
+            if( bNoDetach ) {
+              documentEventHandlers[type].fire(evt);
+            }
+            else {
+              setTimeout(function() {
+                  documentEventHandlers[type].fire(evt);
+              }, 0);
+            }
         } else {
             document.dispatchEvent(evt);
         }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/4a313d03/lib/wp7/plugin/wp7/CordovaCommandResult.js
----------------------------------------------------------------------
diff --git a/lib/wp7/plugin/wp7/CordovaCommandResult.js b/lib/wp7/plugin/wp7/CordovaCommandResult.js
index 2f7da8a..99b4643 100644
--- a/lib/wp7/plugin/wp7/CordovaCommandResult.js
+++ b/lib/wp7/plugin/wp7/CordovaCommandResult.js
@@ -6,7 +6,8 @@ var channel = require('cordova/channel');
 module.exports = function(status,callbackId,args,cast) {
 
     if(status === "backbutton") {
-        cordova.fireDocumentEvent("backbutton");
+        // do not detach backbutton event, as we need to be able to catch exceptions
+        cordova.fireDocumentEvent("backbutton", undefined, true);
         return "true";
     }
     else if(status === "resume") {


Mime
View raw message