This commit is contained in:
ldeluca 2014-06-11 09:58:52 -04:00
commit 89ae9dbd53
7 changed files with 179 additions and 52 deletions

View File

@ -1,3 +1,24 @@
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
-->
# Contributing to Apache Cordova # Contributing to Apache Cordova
Anyone can contribute to Cordova. And we need your contributions. Anyone can contribute to Cordova. And we need your contributions.

View File

@ -97,3 +97,18 @@
* CB-6212: [iOS] fix warnings compiled under arm64 64-bit * CB-6212: [iOS] fix warnings compiled under arm64 64-bit
* CB-6218: Update docs for BB10 * CB-6218: Update docs for BB10
* CB-6460: Update license headers * CB-6460: Update license headers
### 0.5.0 (Jun 05, 2014)
* CB-6127 Spanish and rench Translations added. Github close #23
* Clean up whitespace (mainly due to no newline at eof warning)
* Adding permission info
* CB-6806 Add license
* CB-6491 add CONTRIBUTING.md
* Add necessary capability so the plugin works on its own
* CB-6474 InAppBrowser. Add data urls support to WP8
* CB-6482 InAppBrowser calls incorrect callback on WP8
* Fixed use of iOS 6 deprecated methods
* CB-6360 - improvement: feature detection instead of iOS version detection
* CB-5649 - InAppBrowser overrides App's orientation
* refactoring fixed
* CB-6396 [Firefox OS] Adding basic support

View File

@ -30,17 +30,6 @@ and can't access Cordova APIs.
cordova plugin add org.apache.cordova.inappbrowser cordova plugin add org.apache.cordova.inappbrowser
### Firefox OS
Create __www/manifest.webapp__ as described in
[Manifest Docs](https://developer.mozilla.org/en-US/Apps/Developing/Manifest).
Add relevant permisions.
"permissions": {
"browser": {}
}
## window.open ## window.open
Opens a URL in a new `InAppBrowser` instance, the current browser Opens a URL in a new `InAppBrowser` instance, the current browser
@ -93,6 +82,7 @@ instance, or the system browser.
- Amazon Fire OS - Amazon Fire OS
- Android - Android
- BlackBerry 10 - BlackBerry 10
- Firefox OS
- iOS - iOS
- Windows Phone 7 and 8 - Windows Phone 7 and 8
@ -101,6 +91,38 @@ instance, or the system browser.
var ref = window.open('http://apache.org', '_blank', 'location=yes'); var ref = window.open('http://apache.org', '_blank', 'location=yes');
var ref2 = window.open(encodeURI('http://ja.m.wikipedia.org/wiki/ハングル'), '_blank', 'location=yes'); var ref2 = window.open(encodeURI('http://ja.m.wikipedia.org/wiki/ハングル'), '_blank', 'location=yes');
### Firefox OS Quirks
As plugin doesn't enforce any design there is a need to add some CSS rules if
opened with `target='_blank'`. The rules might look like these
``` css
.inAppBrowserWrap {
background-color: rgba(0,0,0,0.75);
color: rgba(235,235,235,1.0);
}
.inAppBrowserWrap menu {
overflow: auto;
list-style-type: none;
padding-left: 0;
}
.inAppBrowserWrap menu li {
font-size: 25px;
height: 25px;
float: left;
margin: 0 10px;
padding: 3px 10px;
text-decoration: none;
color: #ccc;
display: block;
background: rgba(30,30,30,0.50);
}
.inAppBrowserWrap menu li.disabled {
color: #777;
}
```
## InAppBrowser ## InAppBrowser
The object returned from a call to `window.open`. The object returned from a call to `window.open`.
@ -198,6 +220,7 @@ The function is passed an `InAppBrowserEvent` object.
- Amazon Fire OS - Amazon Fire OS
- Android - Android
- Firefox OS
- iOS - iOS
- Windows Phone 7 and 8 - Windows Phone 7 and 8

View File

@ -20,7 +20,7 @@
<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.4.1-dev"> version="0.5.1-dev">
<name>InAppBrowser</name> <name>InAppBrowser</name>
<description>Cordova InAppBrowser Plugin</description> <description>Cordova InAppBrowser Plugin</description>
@ -165,6 +165,9 @@
<!-- firefoxos --> <!-- firefoxos -->
<platform name="firefoxos"> <platform name="firefoxos">
<config-file target="config.xml" parent="/*">
<permission name="browser" description="Enables the app to implement a browser in an iframe." />
</config-file>
<js-module src="www/inappbrowser.js" name="inappbrowser"> <js-module src="www/inappbrowser.js" name="inappbrowser">
<clobbers target="window.open" /> <clobbers target="window.open" />
</js-module> </js-module>

View File

@ -47,10 +47,34 @@ var IABExecs = {
open: function (win, lose, args) { open: function (win, lose, args) {
var strUrl = args[0], var strUrl = args[0],
target = args[1], target = args[1],
features = args[2], features_string = args[2] || "location=yes", //location=yes is default
features = {},
url, url,
elem; elem;
var features_list = features_string.split(',');
features_list.forEach(function(feature) {
var tup = feature.split('=');
if (tup[1] == 'yes') {
tup[1] = true;
} else if (tup[1] == 'no') {
tup[1] = false;
} else {
var number = parseInt(tup[1]);
if (!isNaN(number)) {
tup[1] = number;
}
}
features[tup[0]] = tup[1];
});
function updateIframeSizeNoLocation() {
browserWrap.style.width = window.innerWidth + 'px';
browserWrap.style.height = window.innerHeight + 'px';
browserWrap.browser.style.height = (window.innerHeight - 60) + 'px';
browserWrap.browser.style.width = browserWrap.style.width;
}
if (target === '_system') { if (target === '_system') {
origOpenFunc.apply(window, [strUrl, '_blank']); origOpenFunc.apply(window, [strUrl, '_blank']);
} else if (target === '_blank') { } else if (target === '_blank') {
@ -63,34 +87,73 @@ var IABExecs = {
document.body.removeChild(browserWrap); document.body.removeChild(browserWrap);
} }
browserWrap = document.createElement('div'); browserWrap = document.createElement('div');
// assign browser element to browserWrap for future reference
browserWrap.browser = browserElem;
browserWrap.classList.add('inAppBrowserWrap');
browserWrap.style.position = 'absolute'; browserWrap.style.position = 'absolute';
browserWrap.style.backgroundColor = 'rgba(0,0,0,0.75)';
browserWrap.style.color = 'rgba(235,235,235,1.0)';
browserWrap.style.width = window.innerWidth + 'px';
browserWrap.style.height = window.innerHeight + 'px';
browserWrap.style.padding = '10px,0,0,0';
browserElem.style.position = 'absolute'; browserElem.style.position = 'absolute';
browserElem.style.border = 0;
browserElem.style.top = '60px'; browserElem.style.top = '60px';
browserElem.style.left = '0px'; browserElem.style.left = '0px';
browserElem.style.height = (window.innerHeight - 60) + 'px'; updateIframeSizeNoLocation();
browserElem.style.width = browserWrap.style.width;
browserWrap.addEventListener('click', function () { var menu = document.createElement('menu');
menu.setAttribute('type', 'toolbar');
var close = document.createElement('li');
var back = document.createElement('li');
var forward = document.createElement('li');
close.appendChild(document.createTextNode('×'));
back.appendChild(document.createTextNode('<'));
forward.appendChild(document.createTextNode('>'));
close.classList.add('inAppBrowserClose');
back.classList.add('inAppBrowserBack');
forward.classList.add('inAppBrowserForward');
function checkForwardBackward() {
var backReq = browserElem.getCanGoBack();
backReq.onsuccess = function() {
if (this.result) {
back.classList.remove('disabled');
} else {
back.classList.add('disabled');
}
}
var forwardReq = browserElem.getCanGoForward();
forwardReq.onsuccess = function() {
if (this.result) {
forward.classList.remove('disabled');
} else {
forward.classList.add('disabled');
}
}
};
browserElem.addEventListener('mozbrowserloadend', checkForwardBackward);
close.addEventListener('click', function () {
setTimeout(function () { setTimeout(function () {
IABExecs.close(); IABExecs.close();
}, 0); }, 0);
}, false); }, false);
var p = document.createElement('p');
p.appendChild(document.createTextNode('close')); back.addEventListener('click', function () {
// TODO: make all buttons - ← → × browserElem.goBack();
p.style.paddingTop = '10px'; }, false);
p.style.textAlign = 'center';
browserWrap.appendChild(p); forward.addEventListener('click', function () {
browserElem.goForward();
}, false);
menu.appendChild(back);
menu.appendChild(forward);
menu.appendChild(close);
browserWrap.appendChild(menu);
browserWrap.appendChild(browserElem); browserWrap.appendChild(browserElem);
document.body.appendChild(browserWrap); document.body.appendChild(browserWrap);
// assign browser element to browserWrap for future
// reference
browserWrap.browser = browserElem;
} else { } else {
window.location = strUrl; window.location = strUrl;
} }

View File

@ -98,4 +98,5 @@
@property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate; @property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate;
@end @end

View File

@ -73,7 +73,7 @@
if ([[url host] isEqualToString:@"itunes.apple.com"]) { if ([[url host] isEqualToString:@"itunes.apple.com"]) {
return YES; return YES;
} }
return NO; return NO;
} }
@ -90,7 +90,7 @@
if (url != nil) { if (url != nil) {
NSURL* baseUrl = [self.webView.request URL]; NSURL* baseUrl = [self.webView.request URL];
NSURL* absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] absoluteURL]; NSURL* absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] absoluteURL];
if ([self isSystemUrl:absoluteUrl]) { if ([self isSystemUrl:absoluteUrl]) {
target = kInAppBrowserTargetSystem; target = kInAppBrowserTargetSystem;
} }
@ -187,7 +187,7 @@
} }
} }
} }
// UIWebView options // UIWebView options
self.inAppBrowserViewController.webView.scalesPageToFit = browserOptions.enableviewportscale; self.inAppBrowserViewController.webView.scalesPageToFit = browserOptions.enableviewportscale;
self.inAppBrowserViewController.webView.mediaPlaybackRequiresUserAction = browserOptions.mediaplaybackrequiresuseraction; self.inAppBrowserViewController.webView.mediaPlaybackRequiresUserAction = browserOptions.mediaplaybackrequiresuseraction;
@ -196,7 +196,7 @@
self.inAppBrowserViewController.webView.keyboardDisplayRequiresUserAction = browserOptions.keyboarddisplayrequiresuseraction; self.inAppBrowserViewController.webView.keyboardDisplayRequiresUserAction = browserOptions.keyboarddisplayrequiresuseraction;
self.inAppBrowserViewController.webView.suppressesIncrementalRendering = browserOptions.suppressesincrementalrendering; self.inAppBrowserViewController.webView.suppressesIncrementalRendering = browserOptions.suppressesincrementalrendering;
} }
[self.inAppBrowserViewController navigateTo:url]; [self.inAppBrowserViewController navigateTo:url];
if (!browserOptions.hidden) { if (!browserOptions.hidden) {
[self show:nil]; [self show:nil];
@ -213,9 +213,9 @@
NSLog(@"Tried to show IAB while already shown"); NSLog(@"Tried to show IAB while already shown");
return; return;
} }
_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle; _previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
CDVInAppBrowserNavigationController* nav = [[CDVInAppBrowserNavigationController alloc] CDVInAppBrowserNavigationController* nav = [[CDVInAppBrowserNavigationController alloc]
initWithRootViewController:self.inAppBrowserViewController]; initWithRootViewController:self.inAppBrowserViewController];
nav.orientationDelegate = self.inAppBrowserViewController; nav.orientationDelegate = self.inAppBrowserViewController;
@ -439,7 +439,7 @@
// 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;
_previousStatusBarStyle = -1; _previousStatusBarStyle = -1;
if (IsAtLeastiOSVersion(@"7.0")) { if (IsAtLeastiOSVersion(@"7.0")) {
@ -477,7 +477,7 @@
BOOL toolbarIsAtBottom = ![_browserOptions.toolbarposition isEqualToString:kInAppBrowserToolbarBarPositionTop]; BOOL toolbarIsAtBottom = ![_browserOptions.toolbarposition isEqualToString:kInAppBrowserToolbarBarPositionTop];
webViewBounds.size.height -= _browserOptions.location ? FOOTER_HEIGHT : TOOLBAR_HEIGHT; webViewBounds.size.height -= _browserOptions.location ? FOOTER_HEIGHT : TOOLBAR_HEIGHT;
self.webView = [[UIWebView alloc] initWithFrame:webViewBounds]; self.webView = [[UIWebView alloc] initWithFrame:webViewBounds];
self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
[self.view addSubview:self.webView]; [self.view addSubview:self.webView];
@ -519,7 +519,7 @@
float toolbarY = toolbarIsAtBottom ? self.view.bounds.size.height - TOOLBAR_HEIGHT : 0.0; float toolbarY = toolbarIsAtBottom ? self.view.bounds.size.height - TOOLBAR_HEIGHT : 0.0;
CGRect toolbarFrame = CGRectMake(0.0, toolbarY, self.view.bounds.size.width, TOOLBAR_HEIGHT); CGRect toolbarFrame = CGRectMake(0.0, toolbarY, self.view.bounds.size.width, TOOLBAR_HEIGHT);
self.toolbar = [[UIToolbar alloc] initWithFrame:toolbarFrame]; self.toolbar = [[UIToolbar alloc] initWithFrame:toolbarFrame];
self.toolbar.alpha = 1.000; self.toolbar.alpha = 1.000;
self.toolbar.autoresizesSubviews = YES; self.toolbar.autoresizesSubviews = YES;
@ -535,7 +535,7 @@
CGFloat labelInset = 5.0; CGFloat labelInset = 5.0;
float locationBarY = toolbarIsAtBottom ? self.view.bounds.size.height - FOOTER_HEIGHT : self.view.bounds.size.height - LOCATIONBAR_HEIGHT; float locationBarY = toolbarIsAtBottom ? self.view.bounds.size.height - FOOTER_HEIGHT : self.view.bounds.size.height - LOCATIONBAR_HEIGHT;
self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(labelInset, locationBarY, self.view.bounds.size.width - labelInset, LOCATIONBAR_HEIGHT)]; self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(labelInset, locationBarY, self.view.bounds.size.width - labelInset, LOCATIONBAR_HEIGHT)];
self.addressLabel.adjustsFontSizeToFitWidth = NO; self.addressLabel.adjustsFontSizeToFitWidth = NO;
self.addressLabel.alpha = 1.000; self.addressLabel.alpha = 1.000;
@ -549,13 +549,13 @@
self.addressLabel.enabled = YES; self.addressLabel.enabled = YES;
self.addressLabel.hidden = NO; self.addressLabel.hidden = NO;
self.addressLabel.lineBreakMode = NSLineBreakByTruncatingTail; self.addressLabel.lineBreakMode = NSLineBreakByTruncatingTail;
if ([self.addressLabel respondsToSelector:NSSelectorFromString(@"setMinimumScaleFactor:")]) { if ([self.addressLabel respondsToSelector:NSSelectorFromString(@"setMinimumScaleFactor:")]) {
[self.addressLabel setValue:@(10.0/[UIFont labelFontSize]) forKey:@"minimumScaleFactor"]; [self.addressLabel setValue:@(10.0/[UIFont labelFontSize]) forKey:@"minimumScaleFactor"];
} else if ([self.addressLabel respondsToSelector:NSSelectorFromString(@"setMinimumFontSize:")]) { } else if ([self.addressLabel respondsToSelector:NSSelectorFromString(@"setMinimumFontSize:")]) {
[self.addressLabel setValue:@(10.0) forKey:@"minimumFontSize"]; [self.addressLabel setValue:@(10.0) forKey:@"minimumFontSize"];
} }
self.addressLabel.multipleTouchEnabled = NO; self.addressLabel.multipleTouchEnabled = NO;
self.addressLabel.numberOfLines = 1; self.addressLabel.numberOfLines = 1;
self.addressLabel.opaque = NO; self.addressLabel.opaque = NO;
@ -668,7 +668,7 @@
if (show) { if (show) {
self.toolbar.hidden = NO; self.toolbar.hidden = NO;
CGRect webViewBounds = self.view.bounds; CGRect webViewBounds = self.view.bounds;
if (locationbarVisible) { if (locationbarVisible) {
// locationBar at the bottom, move locationBar up // locationBar at the bottom, move locationBar up
// put toolBar at the bottom // put toolBar at the bottom
@ -682,7 +682,7 @@
webViewBounds.size.height -= TOOLBAR_HEIGHT; webViewBounds.size.height -= TOOLBAR_HEIGHT;
self.toolbar.frame = toolbarFrame; self.toolbar.frame = toolbarFrame;
} }
if ([toolbarPosition isEqualToString:kInAppBrowserToolbarBarPositionTop]) { if ([toolbarPosition isEqualToString:kInAppBrowserToolbarBarPositionTop]) {
toolbarFrame.origin.y = 0; toolbarFrame.origin.y = 0;
webViewBounds.origin.y += toolbarFrame.size.height; webViewBounds.origin.y += toolbarFrame.size.height;
@ -691,7 +691,7 @@
toolbarFrame.origin.y = (webViewBounds.size.height + LOCATIONBAR_HEIGHT); toolbarFrame.origin.y = (webViewBounds.size.height + LOCATIONBAR_HEIGHT);
} }
[self setWebViewFrame:webViewBounds]; [self setWebViewFrame:webViewBounds];
} else { } else {
self.toolbar.hidden = YES; self.toolbar.hidden = YES;
@ -725,7 +725,7 @@
[CDVUserAgentUtil releaseLock:&_userAgentLockToken]; [CDVUserAgentUtil releaseLock:&_userAgentLockToken];
[super viewDidUnload]; [super viewDidUnload];
} }
- (UIStatusBarStyle)preferredStatusBarStyle - (UIStatusBarStyle)preferredStatusBarStyle
{ {
return UIStatusBarStyleDefault; return UIStatusBarStyleDefault;
@ -735,7 +735,7 @@
{ {
[CDVUserAgentUtil releaseLock:&_userAgentLockToken]; [CDVUserAgentUtil releaseLock:&_userAgentLockToken];
self.currentURL = nil; self.currentURL = nil;
if ((self.navigationDelegate != nil) && [self.navigationDelegate respondsToSelector:@selector(browserExit)]) { if ((self.navigationDelegate != nil) && [self.navigationDelegate respondsToSelector:@selector(browserExit)]) {
[self.navigationDelegate browserExit]; [self.navigationDelegate browserExit];
} }
@ -774,14 +774,14 @@
{ {
[self.webView goForward]; [self.webView goForward];
} }
- (void)viewWillAppear:(BOOL)animated - (void)viewWillAppear:(BOOL)animated
{ {
if (IsAtLeastiOSVersion(@"7.0")) { if (IsAtLeastiOSVersion(@"7.0")) {
[[UIApplication sharedApplication] setStatusBarStyle:[self preferredStatusBarStyle]]; [[UIApplication sharedApplication] setStatusBarStyle:[self preferredStatusBarStyle]];
} }
[self rePositionViews]; [self rePositionViews];
[super viewWillAppear:animated]; [super viewWillAppear:animated];
} }
@ -982,7 +982,7 @@
if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(supportedInterfaceOrientations)]) { if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(supportedInterfaceOrientations)]) {
return [self.orientationDelegate supportedInterfaceOrientations]; return [self.orientationDelegate supportedInterfaceOrientations];
} }
return 1 << UIInterfaceOrientationPortrait; return 1 << UIInterfaceOrientationPortrait;
} }
@ -991,9 +991,10 @@
if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotateToInterfaceOrientation:)]) { if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotateToInterfaceOrientation:)]) {
return [self.orientationDelegate shouldAutorotateToInterfaceOrientation:interfaceOrientation]; return [self.orientationDelegate shouldAutorotateToInterfaceOrientation:interfaceOrientation];
} }
return YES; return YES;
} }
@end @end