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
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-6218: Update docs for BB10
* 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
### 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
Opens a URL in a new `InAppBrowser` instance, the current browser
@ -93,6 +82,7 @@ instance, or the system browser.
- Amazon Fire OS
- Android
- BlackBerry 10
- Firefox OS
- iOS
- 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 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
The object returned from a call to `window.open`.
@ -198,6 +220,7 @@ The function is passed an `InAppBrowserEvent` object.
- Amazon Fire OS
- Android
- Firefox OS
- iOS
- Windows Phone 7 and 8

View File

@ -20,7 +20,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="org.apache.cordova.inappbrowser"
version="0.4.1-dev">
version="0.5.1-dev">
<name>InAppBrowser</name>
<description>Cordova InAppBrowser Plugin</description>
@ -165,6 +165,9 @@
<!-- 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">
<clobbers target="window.open" />
</js-module>

View File

@ -47,10 +47,34 @@ var IABExecs = {
open: function (win, lose, args) {
var strUrl = args[0],
target = args[1],
features = args[2],
features_string = args[2] || "location=yes", //location=yes is default
features = {},
url,
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') {
origOpenFunc.apply(window, [strUrl, '_blank']);
} else if (target === '_blank') {
@ -63,34 +87,73 @@ var IABExecs = {
document.body.removeChild(browserWrap);
}
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.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.border = 0;
browserElem.style.top = '60px';
browserElem.style.left = '0px';
browserElem.style.height = (window.innerHeight - 60) + 'px';
browserElem.style.width = browserWrap.style.width;
updateIframeSizeNoLocation();
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 () {
IABExecs.close();
}, 0);
}, false);
var p = document.createElement('p');
p.appendChild(document.createTextNode('close'));
// TODO: make all buttons - ← → ×
p.style.paddingTop = '10px';
p.style.textAlign = 'center';
browserWrap.appendChild(p);
back.addEventListener('click', function () {
browserElem.goBack();
}, false);
forward.addEventListener('click', function () {
browserElem.goForward();
}, false);
menu.appendChild(back);
menu.appendChild(forward);
menu.appendChild(close);
browserWrap.appendChild(menu);
browserWrap.appendChild(browserElem);
document.body.appendChild(browserWrap);
// assign browser element to browserWrap for future
// reference
browserWrap.browser = browserElem;
} else {
window.location = strUrl;
}

View File

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

View File

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