Updated Branches:
  refs/heads/master be295511a -> ea5d5ec05

Update remaining stringByEvaluatingJavascriptString calls

To use commandDelegate.evalJs instead.


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

Branch: refs/heads/master
Commit: ea5d5ec0521bcc77c8c2fddf2ee413b3f661b53c
Parents: be29551
Author: Andrew Grieve <agri...@chromium.org>
Authored: Wed Oct 10 14:51:05 2012 -0400
Committer: Andrew Grieve <agri...@chromium.org>
Committed: Wed Oct 10 14:52:49 2012 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/CDVDevice.m         |   10 ++--------
 CordovaLib/Classes/CDVViewController.m |   20 ++++++++------------
 2 files changed, 10 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ea5d5ec0/CordovaLib/Classes/CDVDevice.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVDevice.m b/CordovaLib/Classes/CDVDevice.m
index 879868c..bd170e3 100644
--- a/CordovaLib/Classes/CDVDevice.m
+++ b/CordovaLib/Classes/CDVDevice.m
@@ -27,7 +27,6 @@
 - (void)getDeviceInfo:(CDVInvokedUrlCommand*)command
 {
     NSDictionary* deviceProperties = [self deviceProperties];
-    NSMutableString* result = [[NSMutableString alloc] initWithFormat:@""];
     CDVPluginResult* pluginResult = [CDVPluginResult 
resultWithStatus:CDVCommandStatus_OK messageAsDictionary:deviceProperties];
 
     /* Settings.plist
@@ -39,13 +38,8 @@
     NSDictionary* temp = [CDVViewController getBundlePlist:@"Settings"];
 
     if ([temp respondsToSelector:@selector(JSONString)]) {
-        [result appendFormat:@"\nwindow.Settings = %@;", [temp 
cdvjk_JSONString]];
-    }
-
-    NSString* jsResult = [self.webView 
stringByEvaluatingJavaScriptFromString:result];
-    // if jsResult is not nil nor empty, an error
-    if ((jsResult != nil) && ([jsResult length] > 0)) {
-        NSLog(@"%@", jsResult);
+        NSString* js = [NSString stringWithFormat:@"window.Settings = %@;", 
[temp cdvjk_JSONString]];
+        [self.commandDelegate evalJs:js];
     }
 
     [self.commandDelegate sendPluginResult:pluginResult 
callbackId:command.callbackId];

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ea5d5ec0/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m 
b/CordovaLib/Classes/CDVViewController.m
index f253a2f..987ecee 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -338,11 +338,7 @@
 {
     // First, ask the webview via JS if it supports the new orientation
     NSString* jsCall = [NSString stringWithFormat:
-        @"(function(){ \
-                                if('shouldRotateToOrientation' in window) { \
-                                    return 
window.shouldRotateToOrientation(%d); \
-                                } \
-                            })()"
+        @"window.shouldRotateToOrientation && 
window.shouldRotateToOrientation(%d);"
         , [self mapIosOrientationToJsOrientation:interfaceOrientation]];
     NSString* res = [webView stringByEvaluatingJavaScriptFromString:jsCall];
 
@@ -395,7 +391,7 @@
             @"window.__defineGetter__('orientation',function(){ return %d; }); 
\
                                   
cordova.fireWindowEvent('orientationchange');"
             , [self 
mapIosOrientationToJsOrientation:fromInterfaceOrientation]];
-        [self.webView stringByEvaluatingJavaScriptFromString:jsCallback];
+        [self.commandDelegate evalJs:jsCallback];
     }
 }
 
@@ -490,7 +486,7 @@
     // The .onNativeReady().fire() will work when cordova.js is already loaded.
     // The _nativeReady = true; is used when this is run before cordova.js is 
loaded.
     NSString* nativeReady = [NSString 
stringWithFormat:@"cordova.iOSVCAddr='%lld';try{cordova.require('cordova/channel').onNativeReady.fire();}catch(e){window._nativeReady
 = true;}", (long long)self];
-    [theWebView stringByEvaluatingJavaScriptFromString:nativeReady];
+    [self.commandDelegate evalJs:nativeReady];
 }
 
 - (void)webView:(UIWebView*)webView didFailLoadWithError:(NSError*)error
@@ -600,7 +596,7 @@
 {
     NSString* jsString = [NSString stringWithFormat:@"alert('%@');", text];
 
-    [webView stringByEvaluatingJavaScriptFromString:jsString];
+    [self.commandDelegate evalJs:jsString];
 }
 
 + (NSString*)resolveImageResource:(NSString*)resource
@@ -876,7 +872,7 @@ BOOL gSplashScreenShown = NO;
 - (void)onAppWillResignActive:(NSNotification*)notification
 {
     // NSLog(@"%@",@"applicationWillResignActive");
-    [self.webView 
stringByEvaluatingJavaScriptFromString:@"cordova.fireDocumentEvent('resign');"];
+    [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('resign');"];
 }
 
 /*
@@ -887,14 +883,14 @@ BOOL gSplashScreenShown = NO;
 - (void)onAppWillEnterForeground:(NSNotification*)notification
 {
     // NSLog(@"%@",@"applicationWillEnterForeground");
-    [self.webView 
stringByEvaluatingJavaScriptFromString:@"cordova.fireDocumentEvent('resume');"];
+    [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('resume');"];
 }
 
 // This method is called to let your application know that it moved from the 
inactive to active state.
 - (void)onAppDidBecomeActive:(NSNotification*)notification
 {
     // NSLog(@"%@",@"applicationDidBecomeActive");
-    [self.webView 
stringByEvaluatingJavaScriptFromString:@"cordova.fireDocumentEvent('active');"];
+    [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('active');"];
 }
 
 /*
@@ -904,7 +900,7 @@ BOOL gSplashScreenShown = NO;
 - (void)onAppDidEnterBackground:(NSNotification*)notification
 {
     // NSLog(@"%@",@"applicationDidEnterBackground");
-    [self.webView 
stringByEvaluatingJavaScriptFromString:@"cordova.fireDocumentEvent('pause');"];
+    [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('pause');"];
 }
 
 // ///////////////////////

Reply via email to