Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser
This commit is contained in:
commit
89ae9dbd53
@ -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.
|
||||||
|
@ -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
|
||||||
|
45
doc/index.md
45
doc/index.md
@ -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
|
||||||
|
|
||||||
|
@ -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>
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -99,3 +99,4 @@
|
|||||||
@property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate;
|
@property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -997,3 +997,4 @@
|
|||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user