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

ios commit: [CB-683] pause/resume events now should pass in event object into handlers

Updated Branches:
  refs/heads/master 965335659 -> 0a4dbf0ff


[CB-683] pause/resume events now should pass in event object into handlers


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

Branch: refs/heads/master
Commit: 0a4dbf0ff7933769f658a780623d29dd42563767
Parents: 9653356
Author: Fil Maj <ma...@gmail.com>
Authored: Thu May 10 16:44:12 2012 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu May 10 16:44:12 2012 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDVViewController.m |    4 +-
 CordovaLib/javascript/cordova.ios.js   |   54 +++++++++++++++-----------
 2 files changed, 33 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/0a4dbf0f/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index 6cdcfaa..7abe82c 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -979,7 +979,7 @@ static NSString* cdvVersion;
 - (void) onAppWillEnterForeground:(NSNotification*)notification
 {
     //NSLog(@"%@",@"applicationWillEnterForeground");
-    [self.webView stringByEvaluatingJavaScriptFromString:@"cordova.require('cordova/channel').onResume.fire();"];
+    [self.webView stringByEvaluatingJavaScriptFromString:@"cordova.fireDocumentEvent('resume');"];
 }
 
 // This method is called to let your application know that it moved from the inactive to active state. 
@@ -996,7 +996,7 @@ static NSString* cdvVersion;
 - (void) onAppDidEnterBackground:(NSNotification*)notification
 {
     //NSLog(@"%@",@"applicationDidEnterBackground");
-    [self.webView stringByEvaluatingJavaScriptFromString:@"cordova.require('cordova/channel').onPause.fire();"];
+    [self.webView stringByEvaluatingJavaScriptFromString:@"cordova.fireDocumentEvent('pause');"];
 }
 
 // ///////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/0a4dbf0f/CordovaLib/javascript/cordova.ios.js
----------------------------------------------------------------------
diff --git a/CordovaLib/javascript/cordova.ios.js b/CordovaLib/javascript/cordova.ios.js
index 9063d6a..e86afd5 100644
--- a/CordovaLib/javascript/cordova.ios.js
+++ b/CordovaLib/javascript/cordova.ios.js
@@ -1,6 +1,6 @@
-// commit a5f0a62f9a9dc5fd7af95ec3d09b6b17c0b89b44
+// commit facaa38a0bd924aa15c14c372537c00382f1e593
 
-// File generated at :: Mon May 07 2012 16:20:11 GMT-0700 (PDT)
+// File generated at :: Thu May 10 2012 16:39:13 GMT-0700 (PDT)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -98,17 +98,7 @@ var documentEventHandlers = {},
 
 document.addEventListener = function(evt, handler, capture) {
     var e = evt.toLowerCase();
-    if (e == 'deviceready') {
-        channel.onDeviceReady.subscribeOnce(handler);
-    } else if (e == 'resume') {
-        channel.onResume.subscribe(handler);
-        // if subscribing listener after event has already fired, invoke the handler
-        if (channel.onResume.fired && typeof handler == 'function') {
-            handler();
-        }
-    } else if (e == 'pause') {
-        channel.onPause.subscribe(handler);
-    } else if (typeof documentEventHandlers[e] != 'undefined') {
+    if (typeof documentEventHandlers[e] != 'undefined') {
         documentEventHandlers[e].subscribe(handler);
     } else {
         m_document_addEventListener.call(document, evt, handler, capture);
@@ -126,13 +116,8 @@ window.addEventListener = function(evt, handler, capture) {
 
 document.removeEventListener = function(evt, handler, capture) {
     var e = evt.toLowerCase();
-    // Check for pause/resume events first.
-    if (e == 'resume') {
-        channel.onResume.unsubscribe(handler);
-    } else if (e == 'pause') {
-        channel.onPause.unsubscribe(handler);
     // If unsubcribing from an event that is handled by a plugin
-    } else if (typeof documentEventHandlers[e] != "undefined") {
+    if (typeof documentEventHandlers[e] != "undefined") {
         documentEventHandlers[e].unsubscribe(handler);
     } else {
         m_document_removeEventListener.call(document, evt, handler, capture);
@@ -318,6 +303,11 @@ var cordova = {
     }
 };
 
+// Register pause, resume and deviceready channels as events on document.
+channel.onPause = cordova.addDocumentEventHandler('pause');
+channel.onResume = cordova.addDocumentEventHandler('resume');
+channel.onDeviceReady = cordova.addDocumentEventHandler('deviceready');
+
 // Adds deprecation warnings to functions of an object (but only logs a message once)
 function deprecateFunctions(obj, objLabel) {
     var newObj = {};
@@ -645,10 +635,13 @@ Channel.prototype.unsubscribe = function(g) {
     if (g === null || g === undefined) { throw "You must pass _something_ into Channel.unsubscribe"; }
 
     if (typeof g == 'function') { g = g.observer_guid; }
-    this.handlers[g] = null;
-    delete this.handlers[g];
-    this.numHandlers--;
-    if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
+    var handler = this.handlers[g];
+    if (handler) {
+        this.handlers[g] = null;
+        delete this.handlers[g];
+        this.numHandlers--;
+        if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
+    }
 };
 
 /**
@@ -1901,6 +1894,21 @@ Entry.prototype.getMetadata = function(successCallback, errorCallback) {
 };
 
 /**
+ * Set the metadata of the entry.
+ *
+ * @param successCallback
+ *            {Function} is called with a Metadata object
+ * @param errorCallback
+ *            {Function} is called with a FileError
+ * @param metadataObject
+ *            {Object} keys and values to set
+ */
+Entry.prototype.setMetadata = function(successCallback, errorCallback, metadataObject) {
+
+  exec(successCallback, errorCallback, "File", "setMetadata", [this.fullPath, metadataObject]);
+};
+
+/**
  * Move a file or directory to a new location.
  *
  * @param parent