Compare commits

...

15 Commits

Author SHA1 Message Date
Steven Gill a8060219d5 fixed merge conflict 2013-10-28 12:13:43 -07:00
Steven Gill e5868f8ecb [CB-5188] Updated version and RELEASENOTES.md for release 0.2.4 2013-10-28 12:03:26 -07:00
hermwong b3348cff6c CB-5128: added repo + issue tag to plugin.xml for inappbrowser plugin 2013-10-22 13:40:00 -07:00
Andrew Grieve aa81c3267a CB-4995 Fix crash when WebView is quickly opened then closed.
Also fixes a leak where callback was never being cleared.
2013-10-21 13:19:13 -04:00
Shazron Abdullah c7972b6cff CB-4930 - iOS - InAppBrowser should take into account the status bar 2013-10-15 15:00:09 -07:00
Steven Gill ce7a796cb0 [CB-5010] Incremented plugin version on dev branch. 2013-10-10 10:56:18 -07:00
Steven Gill a76a0a3920 [CB-5010] Updated version and RELEASENOTES.md for release 0.2.3 2013-10-10 10:56:18 -07:00
Andrew Grieve 5ef5171003 CB-4858 - Run IAB methods on the UI thread. 2013-10-10 12:40:27 -04:00
Andrew Grieve 8a6bc01814 CB-4858 Convert relative URLs to absolute URLs in JS 2013-10-10 12:21:35 -04:00
Andrew Grieve 8df4b7d03b CB-3747 Fix back button having different dismiss logic from the close button.
Also made the IAB close when the owner page is navigated (implemented
onReset).
2013-10-10 11:51:58 -04:00
Andrew Grieve 8cd786b603 CB-5021 Expose closeDialog() as a public function and make it safe to call multiple times. 2013-10-10 08:07:46 -04:00
Andrew Grieve ef5eddac9a CB-5021 Make it safe to call close() multiple times 2013-10-09 21:25:24 -04:00
Steven Gill 4d4d479b3c [CB-5010] Updated version and RELEASENOTES.md for release 0.2.3 2013-10-09 15:27:18 -07:00
Steven Gill 3d8b04f982 [CB-4915] Incremented plugin version on dev branch. 2013-09-26 15:26:55 -07:00
Carlos Santana 12bc5d7d8b [CB-4926] Fixes inappbrowser plugin loading for windows8 2013-09-26 13:53:33 -04:00
6 changed files with 276 additions and 213 deletions
+17
View File
@@ -32,3 +32,20 @@
* Rename CHANGELOG.md -> RELEASENOTES.md * Rename CHANGELOG.md -> RELEASENOTES.md
* [CB-4792] Added keepCallback to the show function. * [CB-4792] Added keepCallback to the show function.
* [CB-4752] Incremented plugin version on dev branch. * [CB-4752] Incremented plugin version on dev branch.
### 0.2.3 (Oct 9, 2013)
* [CB-4915] Incremented plugin version on dev branch.
* [CB-4926] Fixes inappbrowser plugin loading for windows8
### 0.2.4 (Oct 28, 2013)
* CB-5128: added repo + issue tag to plugin.xml for inappbrowser plugin
* CB-4995 Fix crash when WebView is quickly opened then closed.
* CB-4930 - iOS - InAppBrowser should take into account the status bar
* [CB-5010] Incremented plugin version on dev branch.
* [CB-5010] Updated version and RELEASENOTES.md for release 0.2.3
* CB-4858 - Run IAB methods on the UI thread.
* CB-4858 Convert relative URLs to absolute URLs in JS
* CB-3747 Fix back button having different dismiss logic from the close button.
* CB-5021 Expose closeDialog() as a public function and make it safe to call multiple times.
* CB-5021 Make it safe to call close() multiple times
>>>>>>> dev
+7 -1
View File
@@ -2,12 +2,18 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="org.apache.cordova.inappbrowser" id="org.apache.cordova.inappbrowser"
version="0.2.2"> version="0.2.4">
<name>InAppBrowser</name> <name>InAppBrowser</name>
<description>Cordova InAppBrowser Plugin</description> <description>Cordova InAppBrowser Plugin</description>
<license>Apache 2.0</license> <license>Apache 2.0</license>
<keywords>cordova,in,app,browser,inappbrowser</keywords> <keywords>cordova,in,app,browser,inappbrowser</keywords>
<repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git</repo>
<issue>https://issues.apache.org/jira/browse/CB/component/12320641</issue>
<engines>
<engine name="cordova" version=">=3.1.0" /><!-- Needs cordova/urlutil -->
</engines>
<js-module src="www/InAppBrowser.js" name="InAppBrowser"> <js-module src="www/InAppBrowser.js" name="InAppBrowser">
<clobbers target="window.open" /> <clobbers target="window.open" />
+77 -77
View File
@@ -18,20 +18,6 @@
*/ */
package org.apache.cordova.inappbrowser; package org.apache.cordova.inappbrowser;
import java.util.HashMap;
import java.util.StringTokenizer;
import org.apache.cordova.Config;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.LOG;
import org.apache.cordova.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
@@ -52,11 +38,7 @@ import android.view.WindowManager.LayoutParams;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.webkit.CookieManager; import android.webkit.CookieManager;
import android.webkit.WebChromeClient;
import android.webkit.GeolocationPermissions.Callback;
import android.webkit.JsPromptResult;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebStorage;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
import android.widget.Button; import android.widget.Button;
@@ -64,6 +46,19 @@ import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.Config;
import org.apache.cordova.CordovaArgs;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.LOG;
import org.apache.cordova.PluginResult;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.StringTokenizer;
@SuppressLint("SetJavaScriptEnabled") @SuppressLint("SetJavaScriptEnabled")
public class InAppBrowser extends CordovaPlugin { public class InAppBrowser extends CordovaPlugin {
@@ -100,29 +95,30 @@ public class InAppBrowser extends CordovaPlugin {
* @param callbackId The callback id used when calling back into JavaScript. * @param callbackId The callback id used when calling back into JavaScript.
* @return A PluginResult object with a status and message. * @return A PluginResult object with a status and message.
*/ */
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
try {
if (action.equals("open")) { if (action.equals("open")) {
this.callbackContext = callbackContext; this.callbackContext = callbackContext;
String url = args.getString(0); final String url = args.getString(0);
String target = args.optString(1); String t = args.optString(1);
if (target == null || target.equals("") || target.equals(NULL)) { if (t == null || t.equals("") || t.equals(NULL)) {
target = SELF; t = SELF;
} }
HashMap<String, Boolean> features = parseFeature(args.optString(2)); final String target = t;
final HashMap<String, Boolean> features = parseFeature(args.optString(2));
Log.d(LOG_TAG, "target = " + target); Log.d(LOG_TAG, "target = " + target);
url = updateUrl(url); this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
String result = ""; String result = "";
// SELF // SELF
if (SELF.equals(target)) { if (SELF.equals(target)) {
Log.d(LOG_TAG, "in self"); Log.d(LOG_TAG, "in self");
// load in webview // load in webview
if (url.startsWith("file://") || url.startsWith("javascript:") if (url.startsWith("file://") || url.startsWith("javascript:")
|| Config.isUrlWhiteListed(url)) { || Config.isUrlWhiteListed(url)) {
this.webView.loadUrl(url); webView.loadUrl(url);
} }
//Load the dialer //Load the dialer
else if (url.startsWith(WebView.SCHEME_TEL)) else if (url.startsWith(WebView.SCHEME_TEL))
@@ -130,34 +126,35 @@ public class InAppBrowser extends CordovaPlugin {
try { try {
Intent intent = new Intent(Intent.ACTION_DIAL); Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse(url)); intent.setData(Uri.parse(url));
this.cordova.getActivity().startActivity(intent); cordova.getActivity().startActivity(intent);
} catch (android.content.ActivityNotFoundException e) { } catch (android.content.ActivityNotFoundException e) {
LOG.e(LOG_TAG, "Error dialing " + url + ": " + e.toString()); LOG.e(LOG_TAG, "Error dialing " + url + ": " + e.toString());
} }
} }
// load in InAppBrowser // load in InAppBrowser
else { else {
result = this.showWebPage(url, features); result = showWebPage(url, features);
} }
} }
// SYSTEM // SYSTEM
else if (SYSTEM.equals(target)) { else if (SYSTEM.equals(target)) {
Log.d(LOG_TAG, "in system"); Log.d(LOG_TAG, "in system");
result = this.openExternal(url); result = openExternal(url);
} }
// BLANK - or anything else // BLANK - or anything else
else { else {
Log.d(LOG_TAG, "in blank"); Log.d(LOG_TAG, "in blank");
result = this.showWebPage(url, features); result = showWebPage(url, features);
} }
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, result); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, result);
pluginResult.setKeepCallback(true); pluginResult.setKeepCallback(true);
this.callbackContext.sendPluginResult(pluginResult); callbackContext.sendPluginResult(pluginResult);
}
});
} }
else if (action.equals("close")) { else if (action.equals("close")) {
closeDialog(); closeDialog();
this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
} }
else if (action.equals("injectScriptCode")) { else if (action.equals("injectScriptCode")) {
String jsWrapper = null; String jsWrapper = null;
@@ -194,13 +191,12 @@ public class InAppBrowser extends CordovaPlugin {
injectDeferredObject(args.getString(0), jsWrapper); injectDeferredObject(args.getString(0), jsWrapper);
} }
else if (action.equals("show")) { else if (action.equals("show")) {
Runnable runnable = new Runnable() { this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
dialog.show(); dialog.show();
} }
}; });
this.cordova.getActivity().runOnUiThread(runnable);
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
pluginResult.setKeepCallback(true); pluginResult.setKeepCallback(true);
this.callbackContext.sendPluginResult(pluginResult); this.callbackContext.sendPluginResult(pluginResult);
@@ -208,12 +204,25 @@ public class InAppBrowser extends CordovaPlugin {
else { else {
return false; return false;
} }
} catch (JSONException e) {
this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
}
return true; return true;
} }
/**
* Called when the view navigates.
*/
@Override
public void onReset() {
closeDialog();
}
/**
* Called by AccelBroker when listener is to be shut down.
* Stop listener.
*/
public void onDestroy() {
closeDialog();
}
/** /**
* Inject an object (script or style) into the InAppBrowser WebView. * Inject an object (script or style) into the InAppBrowser WebView.
* *
@@ -241,8 +250,14 @@ public class InAppBrowser extends CordovaPlugin {
} else { } else {
scriptToInject = source; scriptToInject = source;
} }
final String finalScriptToInject = scriptToInject;
// This action will have the side-effect of blurring the currently focused element // This action will have the side-effect of blurring the currently focused element
this.inAppWebView.loadUrl("javascript:" + scriptToInject); this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
inAppWebView.loadUrl("javascript:" + finalScriptToInject);
}
});
} }
/** /**
@@ -274,20 +289,6 @@ public class InAppBrowser extends CordovaPlugin {
} }
} }
/**
* Convert relative URL to full path
*
* @param url
* @return
*/
private String updateUrl(String url) {
Uri newUrl = Uri.parse(url);
if (newUrl.isRelative()) {
url = this.webView.getUrl().substring(0, this.webView.getUrl().lastIndexOf("/")+1) + url;
}
return url;
}
/** /**
* Display a new browser with the specified URL. * Display a new browser with the specified URL.
* *
@@ -311,30 +312,30 @@ public class InAppBrowser extends CordovaPlugin {
/** /**
* Closes the dialog * Closes the dialog
*/ */
private void closeDialog() { public void closeDialog() {
try {
final WebView childView = this.inAppWebView; final WebView childView = this.inAppWebView;
Runnable runnable = new Runnable() { // The JS protects against multiple calls, so this should happen only when
// closeDialog() is called by other native code.
if (childView == null) {
return;
}
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
childView.loadUrl("about:blank"); childView.loadUrl("about:blank");
if (dialog != null) {
dialog.dismiss();
} }
}
}; });
try {
this.cordova.getActivity().runOnUiThread(runnable);
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
obj.put("type", EXIT_EVENT); obj.put("type", EXIT_EVENT);
sendUpdate(obj, false); sendUpdate(obj, false);
} catch (JSONException ex) { } catch (JSONException ex) {
Log.d(LOG_TAG, "Should never happen"); Log.d(LOG_TAG, "Should never happen");
} }
if (dialog != null) {
dialog.dismiss();
}
} }
/** /**
@@ -438,14 +439,7 @@ public class InAppBrowser extends CordovaPlugin {
dialog.setCancelable(true); dialog.setCancelable(true);
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) {
try { closeDialog();
JSONObject obj = new JSONObject();
obj.put("type", EXIT_EVENT);
sendUpdate(obj, false);
} catch (JSONException e) {
Log.d(LOG_TAG, "Should never happen");
}
} }
}); });
@@ -620,10 +614,16 @@ public class InAppBrowser extends CordovaPlugin {
* *
* @param obj a JSONObject contain event payload information * @param obj a JSONObject contain event payload information
* @param status the status code to return to the JavaScript environment * @param status the status code to return to the JavaScript environment
*/ private void sendUpdate(JSONObject obj, boolean keepCallback, PluginResult.Status status) { */
private void sendUpdate(JSONObject obj, boolean keepCallback, PluginResult.Status status) {
if (callbackContext != null) {
PluginResult result = new PluginResult(status, obj); PluginResult result = new PluginResult(status, obj);
result.setKeepCallback(keepCallback); result.setKeepCallback(keepCallback);
this.callbackContext.sendPluginResult(result); callbackContext.sendPluginResult(result);
if (!keepCallback) {
callbackContext = null;
}
}
} }
+41 -9
View File
@@ -32,6 +32,11 @@
#pragma mark CDVInAppBrowser #pragma mark CDVInAppBrowser
@interface CDVInAppBrowser () {
UIStatusBarStyle _previousStatusBarStyle;
}
@end
@implementation CDVInAppBrowser @implementation CDVInAppBrowser
- (CDVInAppBrowser*)initWithWebView:(UIWebView*)theWebView - (CDVInAppBrowser*)initWithWebView:(UIWebView*)theWebView
@@ -51,12 +56,8 @@
- (void)close:(CDVInvokedUrlCommand*)command - (void)close:(CDVInvokedUrlCommand*)command
{ {
if (self.inAppBrowserViewController != nil) { // Things are cleaned up in browserExit.
[self.inAppBrowserViewController close]; [self.inAppBrowserViewController close];
self.inAppBrowserViewController = nil;
}
self.callbackId = nil;
} }
- (BOOL) isSystemUrl:(NSURL*)url - (BOOL) isSystemUrl:(NSURL*)url
@@ -115,6 +116,7 @@
} }
} }
_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options]; CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options];
[self.inAppBrowserViewController showLocationBar:browserOptions.location]; [self.inAppBrowserViewController showLocationBar:browserOptions.location];
@@ -155,8 +157,13 @@
} }
if (! browserOptions.hidden) { if (! browserOptions.hidden) {
UINavigationController* nav = [[UINavigationController alloc]
initWithRootViewController:self.inAppBrowserViewController];
nav.navigationBarHidden = YES;
if (self.viewController.modalViewController != self.inAppBrowserViewController) { if (self.viewController.modalViewController != self.inAppBrowserViewController) {
[self.viewController presentModalViewController:self.inAppBrowserViewController animated:YES]; [self.viewController presentModalViewController:nav animated:YES];
} }
} }
[self.inAppBrowserViewController navigateTo:url]; [self.inAppBrowserViewController navigateTo:url];
@@ -166,7 +173,13 @@
{ {
if ([self.inAppBrowserViewController isViewLoaded] && self.inAppBrowserViewController.view.window) if ([self.inAppBrowserViewController isViewLoaded] && self.inAppBrowserViewController.view.window)
return; return;
[self.viewController presentModalViewController:self.inAppBrowserViewController animated:YES];
_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
UINavigationController* nav = [[UINavigationController alloc]
initWithRootViewController:self.inAppBrowserViewController];
nav.navigationBarHidden = YES;
[self.viewController presentModalViewController:nav animated:YES];
} }
- (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options - (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
@@ -355,13 +368,18 @@
if (self.callbackId != nil) { if (self.callbackId != nil) {
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsDictionary:@{@"type":@"exit"}]; messageAsDictionary:@{@"type":@"exit"}];
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId]; [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
self.callbackId = nil;
} }
// Set navigationDelegate to nil to ensure no callbacks are received from it.
self.inAppBrowserViewController.navigationDelegate = nil;
// Don't recycle the ViewController since it may be consuming a lot of memory. // Don't recycle the ViewController since it may be consuming a lot of memory.
// Also - this is required for the PDF/User-Agent bug work-around. // Also - this is required for the PDF/User-Agent bug work-around.
self.inAppBrowserViewController = nil; self.inAppBrowserViewController = nil;
if (IsAtLeastiOSVersion(@"7.0")) {
[[UIApplication sharedApplication] setStatusBarStyle:_previousStatusBarStyle];
}
} }
@end @end
@@ -633,6 +651,11 @@
[super viewDidUnload]; [super viewDidUnload];
} }
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleDefault;
}
- (void)close - (void)close
{ {
[CDVUserAgentUtil releaseLock:&_userAgentLockToken]; [CDVUserAgentUtil releaseLock:&_userAgentLockToken];
@@ -675,6 +698,15 @@
[self.webView goForward]; [self.webView goForward];
} }
- (void)viewWillAppear:(BOOL)animated
{
if (IsAtLeastiOSVersion(@"7.0")) {
[[UIApplication sharedApplication] setStatusBarStyle:[self preferredStatusBarStyle]];
}
[super viewWillAppear:animated];
}
#pragma mark UIWebViewDelegate #pragma mark UIWebViewDelegate
- (void)webViewDidStartLoad:(UIWebView*)theWebView - (void)webViewDidStartLoad:(UIWebView*)theWebView
+11 -5
View File
@@ -22,6 +22,7 @@
var exec = require('cordova/exec'); var exec = require('cordova/exec');
var channel = require('cordova/channel'); var channel = require('cordova/channel');
var modulemapper = require('cordova/modulemapper'); var modulemapper = require('cordova/modulemapper');
var urlutil = require('cordova/urlutil');
function InAppBrowser() { function InAppBrowser() {
this.channels = { this.channels = {
@@ -30,6 +31,7 @@ function InAppBrowser() {
'loaderror' : channel.create('loaderror'), 'loaderror' : channel.create('loaderror'),
'exit' : channel.create('exit') 'exit' : channel.create('exit')
}; };
this._alive = true;
} }
InAppBrowser.prototype = { InAppBrowser.prototype = {
@@ -39,7 +41,10 @@ InAppBrowser.prototype = {
} }
}, },
close: function (eventname) { close: function (eventname) {
if (this._alive) {
this._alive = false;
exec(null, null, "InAppBrowser", "close", []); exec(null, null, "InAppBrowser", "close", []);
}
}, },
show: function (eventname) { show: function (eventname) {
exec(null, null, "InAppBrowser", "show", []); exec(null, null, "InAppBrowser", "show", []);
@@ -77,17 +82,18 @@ InAppBrowser.prototype = {
}; };
module.exports = function(strUrl, strWindowName, strWindowFeatures) { module.exports = function(strUrl, strWindowName, strWindowFeatures) {
var iab = new InAppBrowser();
var cb = function(eventname) {
iab._eventHandler(eventname);
};
// Don't catch calls that write to existing frames (e.g. named iframes). // Don't catch calls that write to existing frames (e.g. named iframes).
if (window.frames && window.frames[strWindowName]) { if (window.frames && window.frames[strWindowName]) {
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open'); var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
return origOpenFunc.apply(window, arguments); return origOpenFunc.apply(window, arguments);
} }
strUrl = urlutil.makeAbsolute(strUrl);
var iab = new InAppBrowser();
var cb = function(eventname) {
iab._eventHandler(eventname);
};
exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]); exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
return iab; return iab;
}; };
+23 -21
View File
@@ -1,4 +1,4 @@
cordova.define("org.apache.cordova.inappbrowser.InAppBrowserProxy", function(require, exports, module) { /* /*
* *
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@@ -19,7 +19,8 @@ cordova.define("org.apache.cordova.inappbrowser.InAppBrowserProxy", function(req
* *
*/ */
/*global Windows:true */ /*jslint sloppy:true */
/*global Windows:true, require, document, setTimeout, window, module */
@@ -30,27 +31,29 @@ var browserWrap;
var IAB = { var IAB = {
close: function (win,lose) { close: function (win, lose) {
if (browserWrap) { if (browserWrap) {
browserWrap.parentNode.removeChild(browserWrap); browserWrap.parentNode.removeChild(browserWrap);
browserWrap = null; browserWrap = null;
} }
}, },
show: function (win,lose) { show: function (win, lose) {
/* empty block, ran out of bacon?
if (browserWrap) { if (browserWrap) {
} }*/
}, },
open: function (win,lose,args) { open: function (win, lose, args) {
var strUrl = args[0]; var strUrl = args[0],
var target = args[1]; target = args[1],
var features = args[2]; features = args[2],
url,
elem;
if (target == "_system") { if (target === "_system") {
var url = new Windows.Foundation.Uri(strUrl) url = new Windows.Foundation.Uri(strUrl);
Windows.System.Launcher.launchUriAsync(url); Windows.System.Launcher.launchUriAsync(url);
} } else if (target === "_blank") {
else if (target == "_blank") {
if (!browserWrap) { if (!browserWrap) {
browserWrap = document.createElement("div"); browserWrap = document.createElement("div");
browserWrap.style.position = "absolute"; browserWrap.style.position = "absolute";
@@ -64,13 +67,13 @@ var IAB = {
setTimeout(function () { setTimeout(function () {
IAB.close(); IAB.close();
}, 0); }, 0);
} };
document.body.appendChild(browserWrap); document.body.appendChild(browserWrap);
} }
var elem = document.createElement("iframe"); elem = document.createElement("iframe");
elem.style.width = (window.innerWidth - 80)+ "px"; elem.style.width = (window.innerWidth - 80) + "px";
elem.style.height = (window.innerHeight - 80) + "px"; elem.style.height = (window.innerHeight - 80) + "px";
elem.style.borderWidth = "0px"; elem.style.borderWidth = "0px";
elem.name = "targetFrame"; elem.name = "targetFrame";
@@ -84,8 +87,7 @@ var IAB = {
}); });
browserWrap.appendChild(elem); browserWrap.appendChild(elem);
} } else {
else {
window.location = strUrl; window.location = strUrl;
} }
@@ -93,12 +95,12 @@ var IAB = {
}, },
injectScriptCode:function(code, bCB) { injectScriptCode: function (code, bCB) {
// "(function(d) { var c = d.createElement('script'); c.src = %@; d.body.appendChild(c); })(document)" // "(function(d) { var c = d.createElement('script'); c.src = %@; d.body.appendChild(c); })(document)"
}, },
injectScriptFile:function(file, bCB) { injectScriptFile: function (file, bCB) {
} }
}; };
@@ -106,4 +108,4 @@ var IAB = {
module.exports = IAB; module.exports = IAB;
require("cordova/windows8/commandProxy").add("InAppBrowser",module.exports); require("cordova/windows8/commandProxy").add("InAppBrowser", module.exports);