You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2012/11/29 02:41:19 UTC

ios commit: Interim cordova-js that supports InAppBrowser events

Updated Branches:
  refs/heads/master 02b5fee98 -> 2335d32ed


Interim cordova-js that supports InAppBrowser events


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

Branch: refs/heads/master
Commit: 2335d32ed051bf488529b8490d2ddf280c746ee3
Parents: 02b5fee
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Nov 28 17:41:13 2012 -0800
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Nov 28 17:41:13 2012 -0800

----------------------------------------------------------------------
 CordovaLib/cordova.ios.js |   57 +++++++++++++++++++++++++++++++++-------
 1 files changed, 47 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/2335d32e/CordovaLib/cordova.ios.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.ios.js b/CordovaLib/cordova.ios.js
index 3931257..7cf3cd6 100644
--- a/CordovaLib/cordova.ios.js
+++ b/CordovaLib/cordova.ios.js
@@ -1,6 +1,6 @@
-// commit c46b14085ce80cda5f72d6af22bc22afe4c2151d
+// commit f29591f869db25f7fa52766e4ac5b60ced38a59f
 
-// File generated at :: Mon Nov 26 2012 18:05:56 GMT-0800 (PST)
+// File generated at :: Wed Nov 28 2012 17:33:26 GMT-0800 (PST)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -3221,19 +3221,56 @@ module.exports = GlobalizationError;
 define("cordova/plugin/InAppBrowser", function(require, exports, module) {
 
 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;
 
+
 });
 
 // file: lib/common/plugin/LocalFileSystem.js