cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhigg...@apache.org
Subject webworks commit: [CB-3434] [BlackBerry10] Implemented pause and resume events
Date Tue, 21 May 2013 23:38:46 GMT
Updated Branches:
  refs/heads/master 03bb7b6d7 -> af65933fe


[CB-3434] [BlackBerry10] Implemented pause and resume events

Reviewed by Bryan Higgins <bhiggins@blackberry.com>
Tested by Tracy Li <tli@blackberry.com>


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

Branch: refs/heads/master
Commit: af65933fea8221a14d8197f613f1a0e1ee150fa2
Parents: 03bb7b6
Author: jkeshavarzi <jkeshavarzi@blackberry.com>
Authored: Tue May 21 16:46:20 2013 -0400
Committer: Bryan Higgins <bryan@bryanhiggins.net>
Committed: Tue May 21 19:38:59 2013 -0400

----------------------------------------------------------------------
 blackberry10/framework/lib/framework.js |   36 +++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/af65933f/blackberry10/framework/lib/framework.js
----------------------------------------------------------------------
diff --git a/blackberry10/framework/lib/framework.js b/blackberry10/framework/lib/framework.js
index 7d02c61..5de045c 100644
--- a/blackberry10/framework/lib/framework.js
+++ b/blackberry10/framework/lib/framework.js
@@ -18,7 +18,38 @@ var utils = require('./utils'),
     controllerWebView = require('./controllerWebView'),
     webview = require('./webview'),
     overlayWebView = require('./overlayWebView'),
-    config = require("./config");
+    config = require("./config"),
+    appEvents = require("./events/applicationEvents"),
+    actionMap = {
+        pause: {
+            event: "inactive",
+            trigger: function () {
+                webview.executeJavascript("cordova.fireDocumentEvent('pause')");
+            }
+        },
+        resume: {
+            event: "active",
+            trigger: function () {
+                webview.executeJavascript("cordova.fireDocumentEvent('resume')");
+            }
+        }
+    };
+
+function addEvents() {
+    for (var action in actionMap) {
+        if (actionMap.hasOwnProperty(action)) {
+            appEvents.addEventListener(actionMap[action].event, actionMap[action].trigger);
+        }
+    }
+}
+
+function removeEvents() {
+    for (var action in actionMap) {
+        if (actionMap.hasOwnProperty(action)) {
+            appEvents.removeEventListener(actionMap[action].event, actionMap[action].trigger);
+        }
+    }
+}
 
 function showWebInspectorInfo() {
     var port = window.qnx.webplatform.getApplication().webInspectorPort,
@@ -118,6 +149,8 @@ var _self = {
             debugEnabled : config.debugEnabled
         });
 
+        addEvents();
+
         //if debugging is enabled, show the IP and port for webinspector
         if (config.debugEnabled) {
             callback = function () {
@@ -131,6 +164,7 @@ var _self = {
         }
     },
     stop: function () {
+        removeEvents();
         webview.destroy();
     }
 };


Mime
View raw message