Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Commit

Permalink
reverted iPhone/ChildBrowser for PhoneGap 1.4.1 per Issue #643
Browse files Browse the repository at this point in the history
reverted iPhone/ChildBrowser for PhoneGap 1.4.1 per Issue #643

I will tag relavent commits so PG/CDV version support can easily be
found
  • Loading branch information
RandyMcMillan committed Oct 31, 2012
1 parent 60c88f7 commit 3627523
Show file tree
Hide file tree
Showing 17 changed files with 66 additions and 104 deletions.
Empty file modified iPhone/ChildBrowser/ChildBrowser.bundle/arrow_left.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified iPhone/ChildBrowser/ChildBrowser.bundle/arrow_left@2x.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified iPhone/ChildBrowser/ChildBrowser.bundle/arrow_right.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified iPhone/ChildBrowser/ChildBrowser.bundle/arrow_right@2x.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified iPhone/ChildBrowser/ChildBrowser.bundle/but_refresh.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified iPhone/ChildBrowser/ChildBrowser.bundle/but_refresh@2x.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified iPhone/ChildBrowser/ChildBrowser.bundle/compass.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified iPhone/ChildBrowser/ChildBrowser.bundle/compass@2x.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 27 additions & 34 deletions iPhone/ChildBrowser/ChildBrowser.js 100644 → 100755
@@ -1,80 +1,73 @@
/* MIT licensed */
// (c) 2010 Jesse MacFadyen, Nitobi

/*global PhoneGap/Cordova */
/*global PhoneGap */

function ChildBrowser()
{
// Does nothing
function ChildBrowser() {
// Does nothing
}

// Callback when the location of the page changes
// called from native
ChildBrowser._onLocationChange = function(newLoc)
{
window.plugins.childBrowser.onLocationChange(newLoc);
window.plugins.childBrowser.onLocationChange(newLoc);
};

// Callback when the user chooses the 'Done' button
// called from native
ChildBrowser._onClose = function()
{
window.plugins.childBrowser.onClose();
window.plugins.childBrowser.onClose();
};

// Callback when the user chooses the 'open in Safari' button
// called from native
ChildBrowser._onOpenExternal = function()
{
window.plugins.childBrowser.onOpenExternal();
window.plugins.childBrowser.onOpenExternal();
};

// Pages loaded into the ChildBrowser can execute callback scripts, so be careful to
// check location, and make sure it is a location you trust.
// Warning ... don't exec arbitrary code, it's risky and could fuck up your app.
// called from native
ChildBrowser._onJSCallback = function(js,loc)
{
// Not Implemented
//window.plugins.childBrowser.onJSCallback(js,loc);
// Not Implemented
//window.plugins.childBrowser.onJSCallback(js,loc);
};

/* The interface that you will use to access functionality */

// Show a webpage, will result in a callback to onLocationChange
ChildBrowser.prototype.showWebPage = function(loc)
{
if (typeof PhoneGap !== "undefined")
{
PhoneGap.exec("ChildBrowserCommand.showWebPage", loc);
}
if (typeof Cordova !== "undefined")
{
Cordova.exec("ChildBrowserCommand.showWebPage", loc);
}
PhoneGap.exec("ChildBrowserCommand.showWebPage", loc);
};

// close the browser, will NOT result in close callback
ChildBrowser.prototype.close = function()
{
if (typeof PhoneGap !== "undefined")
{
PhoneGap.exec("ChildBrowserCommand.close");
}
if (typeof Cordova !== "undefined")
{
Cordova.exec("ChildBrowserCommand.close");
}
PhoneGap.exec("ChildBrowserCommand.close");
};

// Not Implemented
ChildBrowser.prototype.jsExec = function(jsString)
{
// Not Implemented!!
//PhoneGap.exec("ChildBrowserCommand.jsExec",jsString);
// Not Implemented!!
//PhoneGap.exec("ChildBrowserCommand.jsExec",jsString);
};

// Note: this plugin does NOT install itself, call this method some time after deviceready to install it
// it will be returned, and also available globally from window.plugins.childBrowser
ChildBrowser.install = function()
{
if(!window.plugins)
{
window.plugins = {
};
}
window.plugins.childBrowser = new ChildBrowser();
return window.plugins.childBrowser;
if(!window.plugins) {
window.plugins = {};
}

window.plugins.childBrowser = new ChildBrowser();
return window.plugins.childBrowser;
};

24 changes: 11 additions & 13 deletions iPhone/ChildBrowser/ChildBrowserCommand.h 100644 → 100755
@@ -1,25 +1,23 @@
//
// PhoneGap ! ChildBrowserCommand
//
//
// Created by Jesse MacFadyen on 10-05-29.
// Copyright 2010 Nitobi. All rights reserved.
// Copyright 2012, Randy McMillan
// Continued maintainance @RandyMcMillan 2010/2011/2012
//

#import <Foundation/Foundation.h>
#ifdef PHONEGAP_FRAMEWORK
#import <PhoneGap/PGPlugin.h>
#endif
//#else
#ifdef CORDOVA_FRAMEWORK
#import <CORDOVA/CDVPlugin.h>
#import <PhoneGap/PGPlugin.h>
#else
#import "PGPlugin.h"
#endif
#import "ChildBrowserViewController.h"


#ifdef PHONEGAP_FRAMEWORK
@interface ChildBrowserCommand : PGPlugin <ChildBrowserDelegate> {
#endif
#ifdef CORDOVA_FRAMEWORK
@interface ChildBrowserCommand : CDVPlugin <ChildBrowserDelegate> {
#endif

@interface ChildBrowserCommand : PGPlugin <ChildBrowserDelegate> {

ChildBrowserViewController* childBrowser;
}

Expand Down
25 changes: 10 additions & 15 deletions iPhone/ChildBrowser/ChildBrowserCommand.m 100644 → 100755
@@ -1,16 +1,18 @@
//

//
//
// Created by Jesse MacFadyen on 10-05-29.
// Copyright 2010 Nitobi. All rights reserved.
// Copyright 2012, Randy McMillan
// Continued maintainance @RandyMcMillan 2010/2011/2012
//

#import "ChildBrowserCommand.h"

#ifdef PHONEGAP_FRAMEWORK
#import <PhoneGap/PhoneGapViewController.h>
#endif
//#else
#ifdef CORDOVA_FRAMEWORK
#import <Cordova/CDVViewController.h>

#else
#import "PhoneGapViewController.h"
#endif


Expand All @@ -30,18 +32,11 @@ - (void) showWebPage:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)o
NSString* strOrientations = [ options objectForKey:@"supportedOrientations"];
NSArray* supportedOrientations = [strOrientations componentsSeparatedByString:@","];
*/
#ifdef PHONEGAP_FRAMEWORK

PhoneGapViewController* cont = (PhoneGapViewController*)[ super appViewController ];
childBrowser.supportedOrientations = cont.supportedOrientations;
[ cont presentModalViewController:childBrowser animated:YES ];
#endif

#ifdef CORDOVA_FRAMEWORK
CDVViewController* cont = (CDVViewController*)[ super viewController ];
childBrowser.supportedOrientations = cont.supportedOrientations;
[ cont presentModalViewController:childBrowser animated:YES ];
#endif


NSString *url = (NSString*) [arguments objectAtIndex:0];


Expand Down
10 changes: 6 additions & 4 deletions iPhone/ChildBrowser/ChildBrowserViewController.h 100644 → 100755
@@ -1,7 +1,9 @@
// Created by Jesse MacFadyen on 10-05-29.
// Copyright 2010 Nitobi. All rights reserved.
// Copyright 2012, Randy McMillan
// Continued maintainance @RandyMcMillan 2010/2011/2012
//
// ChildBrowserViewController.h
//
// Created by Jesse MacFadyen on 21/07/09.
// Copyright 2009 Nitobi. All rights reserved.
//

#import <UIKit/UIKit.h>

Expand Down
38 changes: 8 additions & 30 deletions iPhone/ChildBrowser/ChildBrowserViewController.m 100644 → 100755
@@ -1,7 +1,9 @@
/// Created by Jesse MacFadyen on 10-05-29.
// Copyright 2010 Nitobi. All rights reserved.
// Copyright 2012, Randy McMillan
// Continued maintainance @RandyMcMillan 2010/2011/2012
//
// ChildBrowserViewController.m
//
// Created by Jesse MacFadyen on 21/07/09.
// Copyright 2009 Nitobi. All rights reserved.
//

#import "ChildBrowserViewController.h"

Expand Down Expand Up @@ -104,12 +106,8 @@ -(void)closeBrowser
{
[delegate onClose];
}
if ([self respondsToSelector:@selector(presentingViewController)]) {
//Reference UIViewController.h Line:179 for update to iOS 5 difference - @RandyMcMillan
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
} else {
[[self parentViewController] dismissModalViewControllerAnimated:YES];
}

[ [super parentViewController] dismissModalViewControllerAnimated:YES];
}

-(IBAction) onDoneButtonPress:(id)sender
Expand Down Expand Up @@ -215,25 +213,5 @@ - (void)webViewDidFinishLoad:(UIWebView *)sender

}

/*
- (void)webView:(UIWebView *)wv didFailLoadWithError:(NSError *)error {
NSLog (@"webView:didFailLoadWithError");
[spinner stopAnimating];
addressLabel.text = @"Failed";
if (error != NULL) {
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle: [error localizedDescription]
message: [error localizedFailureReason]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[errorAlert show];
[errorAlert release];
}
}
*/



@end
Empty file modified iPhone/ChildBrowser/ChildBrowserViewController.xib 100644 → 100755
Empty file.
Empty file modified iPhone/ChildBrowser/FBConnectExample/FBConnect.js 100644 → 100755
Empty file.
Empty file modified iPhone/ChildBrowser/FBConnectExample/README.txt 100644 → 100755
Empty file.
12 changes: 4 additions & 8 deletions iPhone/ChildBrowser/README.md → iPhone/ChildBrowser/README.txt 100644 → 100755
@@ -1,25 +1,21 @@
UPDATED March 2 2012 for Cordova 1.5 with limited backwards support for PhoneGap 1.4.1 (minor changes may be needed for anything earlier than 1.3) - @RandyMcMillan

=================================

The child browser allows you to display external webpages within your PhoneGap/Cordova application.

The child browser allows you to display external webpages within your PhoneGap application.

A simple use case would be:

- Users can follow links/buttons to view web content without leaving your app.
- Display web pages/images/videos/pdfs in the ChildBrowser.
- Users can post links, and you don't want your users to exit your app to view the link.

This command creates a popup browser that is shown in front of your app, when the user presses the done button they are simply returned to your app ( actually they never left )

The ChildBrowser has buttons for refreshing, navigating back + forwards, as well as the option to open in Safari.

Note, because this is open source, I could not include the graphics I usually use for the back/forward and safari buttons. I have changed the XIB file to use system buttons ( rewind / fast-forward + action ) Ideally you should modify the XIB to use your own look.

Here is a sample command to open google in a ChildBrowser :
Here is a sample command to open google in a childbrowser :

PhoneGap.exec("ChildBrowserCommand.showWebPage", "http://www.google.com" );
or
Cordova.exec("ChildBrowserCommand.showWebPage", "http://www.google.com" );

=================================

Expand Down

0 comments on commit 3627523

Please sign in to comment.