cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [01/11] wp7 commit: [CB-3406] InAppBrowser script not enabled in time (cherry picked from commit ca5a6e4e6c2d968c357d77ce66ca5fcd39cc53d6)
Date Fri, 26 Apr 2013 19:04:55 GMT
Updated Branches:
  refs/heads/master 43deeaa88 -> ce1d4d974


[CB-3406] InAppBrowser script not enabled in time
(cherry picked from commit ca5a6e4e6c2d968c357d77ce66ca5fcd39cc53d6)


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

Branch: refs/heads/master
Commit: 97e195a44311905956dbd5ea4900e7c0f208850f
Parents: ee19e9c
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Tue Apr 23 14:45:02 2013 -0700
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Tue Apr 23 14:52:16 2013 -0700

----------------------------------------------------------------------
 templates/standalone/Plugins/InAppBrowser.cs |   66 +++++++++++----------
 1 files changed, 34 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/97e195a4/templates/standalone/Plugins/InAppBrowser.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/Plugins/InAppBrowser.cs b/templates/standalone/Plugins/InAppBrowser.cs
index 7829b93..2741355 100644
--- a/templates/standalone/Plugins/InAppBrowser.cs
+++ b/templates/standalone/Plugins/InAppBrowser.cs
@@ -42,20 +42,20 @@ namespace WPCordovaClassLib.Cordova.Commands
             //BrowserOptions opts = JSON.JsonHelper.Deserialize<BrowserOptions>(options);
             string urlLoc = args[0];
             string target = args[1];
-/*
-    _self - opens in the Cordova WebView if url is in the white-list, else it opens in the
InAppBrowser 
-    _blank - always open in the InAppBrowser 
-    _system - always open in the system web browser 
-*/
-            switch (target) 
+            /*
+                _self - opens in the Cordova WebView if url is in the white-list, else it
opens in the InAppBrowser 
+                _blank - always open in the InAppBrowser 
+                _system - always open in the system web browser 
+            */
+            switch (target)
             {
-                case "_blank" :
+                case "_blank":
                     ShowInAppBrowser(urlLoc);
                     break;
-                case "_self" :
+                case "_self":
                     ShowCordovaBrowser(urlLoc);
                     break;
-                case "_system" :
+                case "_system":
                     ShowSystemBrowser(urlLoc);
                     break;
             }
@@ -65,7 +65,7 @@ namespace WPCordovaClassLib.Cordova.Commands
 
         private void ShowCordovaBrowser(string url)
         {
-            Uri loc = new Uri(url,UriKind.RelativeOrAbsolute);
+            Uri loc = new Uri(url, UriKind.RelativeOrAbsolute);
             Deployment.Current.Dispatcher.BeginInvoke(() =>
             {
                 PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
@@ -75,7 +75,7 @@ namespace WPCordovaClassLib.Cordova.Commands
                     if (page != null)
                     {
                         CordovaView cView = page.FindName("CordovaView") as CordovaView;
-                        if(cView != null)
+                        if (cView != null)
                         {
                             WebBrowser br = cView.Browser;
                             br.Navigate(loc);
@@ -94,7 +94,6 @@ namespace WPCordovaClassLib.Cordova.Commands
         }
 
 
-        // Display an inderminate progress indicator
         private void ShowInAppBrowser(string url)
         {
             Uri loc = new Uri(url);
@@ -113,20 +112,21 @@ namespace WPCordovaClassLib.Cordova.Commands
                     {
                         PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
 
+                        string baseImageUrl = "Images/";
+
                         if (page != null)
                         {
                             Grid grid = page.FindName("LayoutRoot") as Grid;
                             if (grid != null)
                             {
                                 browser = new WebBrowser();
-                                browser.Navigate(loc);
-
+                                browser.IsScriptEnabled = true;
                                 browser.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(browser_LoadCompleted);
 
                                 browser.Navigating += new EventHandler<NavigatingEventArgs>(browser_Navigating);
                                 browser.NavigationFailed += new System.Windows.Navigation.NavigationFailedEventHandler(browser_NavigationFailed);
                                 browser.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(browser_Navigated);
-                                browser.IsScriptEnabled = true;
+                                browser.Navigate(loc);
                                 //browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
                                 grid.Children.Add(browser);
                             }
@@ -137,22 +137,23 @@ namespace WPCordovaClassLib.Cordova.Commands
 
                             backButton = new ApplicationBarIconButton();
                             backButton.Text = "Back";
-                            backButton.IconUri = new Uri("/Images/appbar.back.rest.png",
UriKind.Relative);
+
+                            backButton.IconUri = new Uri(baseImageUrl + "appbar.back.rest.png",
UriKind.Relative);
                             backButton.Click += new EventHandler(backButton_Click);
-                            //backButton.IsEnabled = false;
+                            backButton.IsEnabled = false;
                             bar.Buttons.Add(backButton);
 
 
                             fwdButton = new ApplicationBarIconButton();
                             fwdButton.Text = "Forward";
-                            fwdButton.IconUri = new Uri("/Images/appbar.next.rest.png", UriKind.Relative);
+                            fwdButton.IconUri = new Uri(baseImageUrl + "appbar.next.rest.png",
UriKind.Relative);
                             fwdButton.Click += new EventHandler(fwdButton_Click);
-                            //fwdButton.IsEnabled = false;
+                            fwdButton.IsEnabled = false;
                             bar.Buttons.Add(fwdButton);
 
                             ApplicationBarIconButton closeBtn = new ApplicationBarIconButton();
                             closeBtn.Text = "Close";
-                            closeBtn.IconUri = new Uri("/Images/appbar.close.rest.png", UriKind.Relative);
+                            closeBtn.IconUri = new Uri(baseImageUrl + "appbar.close.rest.png",
UriKind.Relative);
                             closeBtn.Click += new EventHandler(closeBtn_Click);
                             bar.Buttons.Add(closeBtn);
 
@@ -166,7 +167,7 @@ namespace WPCordovaClassLib.Cordova.Commands
 
         void browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs
e)
         {
-            
+
         }
 
         void fwdButton_Click(object sender, EventArgs e)
@@ -175,10 +176,10 @@ namespace WPCordovaClassLib.Cordova.Commands
             {
                 try
                 {
-                    //browser.GoForward();
-                    browser.InvokeScript("execScript", "history.forward();");
+                    browser.GoForward();
+                    //browser.InvokeScript("execScript", "history.forward();");
                 }
-                catch(Exception)
+                catch (Exception)
                 {
 
                 }
@@ -191,8 +192,8 @@ namespace WPCordovaClassLib.Cordova.Commands
             {
                 try
                 {
-                    //browser.GoBack();
-                    browser.InvokeScript("execScript", "history.back();");
+                    browser.GoBack();
+                    //browser.InvokeScript("execScript", "history.back();");
                 }
                 catch (Exception)
                 {
@@ -207,7 +208,7 @@ namespace WPCordovaClassLib.Cordova.Commands
         }
 
 
-        public void close(string options="")
+        public void close(string options = "")
         {
             if (browser != null)
             {
@@ -238,11 +239,12 @@ namespace WPCordovaClassLib.Cordova.Commands
 
         void browser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs
e)
         {
-            //if (browser != null)
-            //{
-            //    backButton.IsEnabled = browser.CanGoBack;
-            //    fwdButton.IsEnabled = browser.CanGoForward;
-            //}
+            if (browser != null)
+            {
+                backButton.IsEnabled = browser.CanGoBack;
+                fwdButton.IsEnabled = browser.CanGoForward;
+
+            }
             string message = "{\"type\":\"loadstop\", \"url\":\"" + e.Uri.AbsoluteUri + "\"}";
             PluginResult result = new PluginResult(PluginResult.Status.OK, message);
             result.KeepCallback = true;


Mime
View raw message