Compare commits
7 Commits
revert-927
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
eac7303ff5 | ||
![]() |
f27c663daa | ||
![]() |
2b7288960f | ||
![]() |
bc17634db3 | ||
![]() |
51959ec268 | ||
![]() |
4b3c0f126d | ||
![]() |
44ead0fb34 |
24
README.md
24
README.md
@ -149,20 +149,12 @@ instance, or the system browser.
|
||||
- __toolbarposition__: Set to `top` or `bottom` (default is `bottom`). Causes the toolbar to be at the top or bottom of the window.
|
||||
- __hidespinner__: Set to `yes` or `no` to change the visibility of the loading indicator (defaults to `no`).
|
||||
|
||||
Windows supports these additional options:
|
||||
|
||||
- __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally.
|
||||
- __hardwareback__: works the same way as on Android platform.
|
||||
- __fullscreen__: set to `yes` to create the browser control without a border around it. Please note that if __location=no__ is also specified, there will be no control presented to user to close IAB window.
|
||||
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- OSX
|
||||
- Windows
|
||||
|
||||
### Example
|
||||
|
||||
@ -364,17 +356,11 @@ function downloadListener(params){
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows
|
||||
- OSX
|
||||
|
||||
### Browser Quirks
|
||||
|
||||
`loadstart`, `loaderror`, `message` events are not fired.
|
||||
|
||||
### Windows Quirks
|
||||
|
||||
`message` event is not fired.
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
|
||||
@ -405,7 +391,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
@ -427,7 +412,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
@ -447,7 +431,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
@ -467,7 +450,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- Android
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
@ -499,7 +481,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
@ -512,10 +493,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- only __code__ key is supported.
|
||||
|
||||
### Windows Quirks
|
||||
|
||||
Due to [MSDN docs](https://msdn.microsoft.com/en-us/library/windows.ui.xaml.controls.webview.invokescriptasync.aspx) the invoked script can return only string values, otherwise the parameter, passed to __callback__ will be `[null]`.
|
||||
|
||||
## InAppBrowser.insertCSS
|
||||
|
||||
> Injects CSS into the `InAppBrowser` window. (Only available when the target is set to `'_blank'`)
|
||||
@ -534,7 +511,6 @@ Due to [MSDN docs](https://msdn.microsoft.com/en-us/library/windows.ui.xaml.cont
|
||||
|
||||
- Android
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
|
@ -20,6 +20,31 @@
|
||||
-->
|
||||
# Release Notes
|
||||
|
||||
### 6.0.0 (Nov 10, 2023)
|
||||
* [GH-1033](https://github.com/apache/cordova-plugin-inappbrowser/pull/1033) chore: bump to next major release 6.0.0 & update deependencies
|
||||
* [GH-1032](https://github.com/apache/cordova-plugin-inappbrowser/pull/1032) chore(lint): update eslint config and apply fixes
|
||||
* [GH-1030](https://github.com/apache/cordova-plugin-inappbrowser/pull/1030) fix!: remove deprecated platforms **Windows** & osx
|
||||
* [GH-1031](https://github.com/apache/cordova-plugin-inappbrowser/pull/1031) fix(ios): Remove deprecation warnings and old code
|
||||
* [GH-927](https://github.com/apache/cordova-plugin-inappbrowser/pull/927) fix: explicitly import dependencies, instead of relying on PCH files. This is important in Swift projects, where you cannot use prefix headers.
|
||||
* [GH-968](https://github.com/apache/cordova-plugin-inappbrowser/pull/968) GH-706 **Android**: Allow permissions requests
|
||||
* [GH-1029](https://github.com/apache/cordova-plugin-inappbrowser/pull/1029) chore: update asf config
|
||||
* [GH-1019](https://github.com/apache/cordova-plugin-inappbrowser/pull/1019) feat(android): Download event
|
||||
* [GH-1020](https://github.com/apache/cordova-plugin-inappbrowser/pull/1020) ci(gh-action): Paramedic CI sync
|
||||
* [GH-1015](https://github.com/apache/cordova-plugin-inappbrowser/pull/1015) feat(ios): Make WebView inspectable
|
||||
* [GH-1016](https://github.com/apache/cordova-plugin-inappbrowser/pull/1016) chore: use https urls in tests and `README`
|
||||
* [GH-1017](https://github.com/apache/cordova-plugin-inappbrowser/pull/1017) chore: Update SUPPORT_QUESTION.md template
|
||||
* [GH-977](https://github.com/apache/cordova-plugin-inappbrowser/pull/977) fix(docs): missing xml indicator in code block
|
||||
* [GH-971](https://github.com/apache/cordova-plugin-inappbrowser/pull/971) ci: sync workflow with paramedic
|
||||
* [GH-964](https://github.com/apache/cordova-plugin-inappbrowser/pull/964) dep(npm): bump package-lock v2 w/ rebuild
|
||||
* [GH-957](https://github.com/apache/cordova-plugin-inappbrowser/pull/957) ci(android): update java requirement for `cordova-android`@11
|
||||
* [GH-946](https://github.com/apache/cordova-plugin-inappbrowser/pull/946) fix(android): increase toolbar to 48dp
|
||||
* [GH-912](https://github.com/apache/cordova-plugin-inappbrowser/pull/912) ci(ios): update workflow w/ **iOS** 15
|
||||
* [GH-907](https://github.com/apache/cordova-plugin-inappbrowser/pull/907) ci: add action-badge
|
||||
* [GH-906](https://github.com/apache/cordova-plugin-inappbrowser/pull/906) ci: remove travis & appveyor
|
||||
* [GH-903](https://github.com/apache/cordova-plugin-inappbrowser/pull/903) ci: add gh-actions workflows
|
||||
* [GH-861](https://github.com/apache/cordova-plugin-inappbrowser/pull/861) fix(android): add space between default useragent and custom AppendUserAgent
|
||||
* [GH-881](https://github.com/apache/cordova-plugin-inappbrowser/pull/881) fix(ios): make system open tel, sms, mailto and geo links
|
||||
|
||||
### 5.0.0 (Feb 10, 2021)
|
||||
* [GH-828](https://github.com/apache/cordova-plugin-inappbrowser/pull/828) feat(ios): add `InAppBrowser`StatusBarStyle 'darkcontent' configuration option
|
||||
* [GH-823](https://github.com/apache/cordova-plugin-inappbrowser/pull/823) chore: bump engines requirements
|
||||
|
3967
package-lock.json
generated
3967
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cordova-plugin-inappbrowser",
|
||||
"version": "5.1.0-dev",
|
||||
"version": "6.0.1-dev",
|
||||
"description": "Cordova InAppBrowser Plugin",
|
||||
"types": "./types/index.d.ts",
|
||||
"cordova": {
|
||||
@ -8,9 +8,7 @@
|
||||
"platforms": [
|
||||
"android",
|
||||
"browser",
|
||||
"ios",
|
||||
"osx",
|
||||
"windows"
|
||||
"ios"
|
||||
]
|
||||
},
|
||||
"repository": "github:apache/cordova-plugin-inappbrowser",
|
||||
@ -24,9 +22,7 @@
|
||||
"ecosystem:cordova",
|
||||
"cordova-android",
|
||||
"cordova-browser",
|
||||
"cordova-ios",
|
||||
"cordova-osx",
|
||||
"cordova-windows"
|
||||
"cordova-ios"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "npm run lint",
|
||||
@ -46,7 +42,12 @@
|
||||
"cordova-ios": ">=6.0.0",
|
||||
"cordova": ">=9.0.0"
|
||||
},
|
||||
"6.0.0": {
|
||||
"6.0.1-dev": {
|
||||
"cordova-android": ">=10.0.0",
|
||||
"cordova-ios": ">=6.0.0",
|
||||
"cordova": ">=9.0.0"
|
||||
},
|
||||
"7.0.0": {
|
||||
"cordova": ">100"
|
||||
}
|
||||
}
|
||||
@ -54,6 +55,6 @@
|
||||
"author": "Apache Software Foundation",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@cordova/eslint-config": "^3.0.0"
|
||||
"@cordova/eslint-config": "^5.0.0"
|
||||
}
|
||||
}
|
||||
|
28
plugin.xml
28
plugin.xml
@ -20,7 +20,7 @@
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-inappbrowser"
|
||||
version="5.1.0-dev">
|
||||
version="6.0.1-dev">
|
||||
|
||||
<name>InAppBrowser</name>
|
||||
<description>Cordova InAppBrowser Plugin</description>
|
||||
@ -91,32 +91,6 @@
|
||||
<framework src="CoreGraphics.framework" />
|
||||
</platform>
|
||||
|
||||
<!-- osx -->
|
||||
<platform name="osx">
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
<clobbers target="cordova.InAppBrowser.open" />
|
||||
</js-module>
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="InAppBrowser">
|
||||
<param name="osx-package" value="CDVInAppBrowser" />
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<header-file src="src/osx/CDVInAppBrowser.h" />
|
||||
<source-file src="src/osx/CDVInAppBrowser.m" />
|
||||
</platform>
|
||||
|
||||
<!-- windows -->
|
||||
<platform name="windows">
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
<clobbers target="cordova.InAppBrowser.open" />
|
||||
</js-module>
|
||||
<js-module src="src/windows/InAppBrowserProxy.js" name="InAppBrowserProxy">
|
||||
<runs />
|
||||
</js-module>
|
||||
<asset src="www/inappbrowser.css" target="css/inappbrowser.css" />
|
||||
</platform>
|
||||
|
||||
<!-- browser -->
|
||||
<platform name="browser">
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
|
@ -19,35 +19,35 @@
|
||||
*
|
||||
*/
|
||||
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
const modulemapper = require('cordova/modulemapper');
|
||||
|
||||
var browserWrap, popup, navigationButtonsDiv, navigationButtonsDivInner, backButton, forwardButton, closeButton;
|
||||
let browserWrap, popup, navigationButtonsDiv, navigationButtonsDivInner, backButton, forwardButton, closeButton;
|
||||
|
||||
function attachNavigationEvents (element, callback) {
|
||||
var onError = function () {
|
||||
const onError = function () {
|
||||
try {
|
||||
callback({ type: 'loaderror', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
callback({ type: 'loaderror', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: 'loaderror', url: null }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
callback({ type: 'loaderror', url: null }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
|
||||
}
|
||||
};
|
||||
|
||||
element.addEventListener('pageshow', function () {
|
||||
try {
|
||||
callback({ type: 'loadstart', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
callback({ type: 'loadstart', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: 'loadstart', url: null }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
callback({ type: 'loadstart', url: null }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
|
||||
}
|
||||
});
|
||||
|
||||
element.addEventListener('load', function () {
|
||||
try {
|
||||
callback({ type: 'loadstop', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
callback({ type: 'loadstop', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: 'loadstop', url: null }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
callback({ type: 'loadstop', url: null }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
|
||||
}
|
||||
});
|
||||
|
||||
@ -55,7 +55,7 @@ function attachNavigationEvents (element, callback) {
|
||||
element.addEventListener('abort', onError);
|
||||
}
|
||||
|
||||
var IAB = {
|
||||
const IAB = {
|
||||
close: function (win, lose) {
|
||||
if (browserWrap) {
|
||||
// use the "open" function callback so that the exit event is fired properly
|
||||
@ -74,9 +74,9 @@ var IAB = {
|
||||
},
|
||||
|
||||
open: function (win, lose, args) {
|
||||
var strUrl = args[0];
|
||||
var target = args[1];
|
||||
var features = args[2];
|
||||
const strUrl = args[0];
|
||||
const target = args[1];
|
||||
const features = args[2];
|
||||
|
||||
IAB._win = win;
|
||||
|
||||
@ -200,8 +200,8 @@ var IAB = {
|
||||
},
|
||||
|
||||
injectScriptCode: function (win, fail, args) {
|
||||
var code = args[0];
|
||||
var hasCallback = args[1];
|
||||
const code = args[0];
|
||||
const hasCallback = args[1];
|
||||
|
||||
if (browserWrap && popup) {
|
||||
try {
|
||||
@ -216,7 +216,7 @@ var IAB = {
|
||||
},
|
||||
|
||||
injectScriptFile: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented';
|
||||
const msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented';
|
||||
console.warn(msg);
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
@ -224,7 +224,7 @@ var IAB = {
|
||||
},
|
||||
|
||||
injectStyleCode: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
|
||||
const msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
|
||||
console.warn(msg);
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
@ -232,7 +232,7 @@ var IAB = {
|
||||
},
|
||||
|
||||
injectStyleFile: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented';
|
||||
const msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented';
|
||||
console.warn(msg);
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
|
@ -19,13 +19,7 @@
|
||||
|
||||
#import "CDVWKInAppBrowser.h"
|
||||
#import <Cordova/NSDictionary+CordovaPreferences.h>
|
||||
|
||||
#if __has_include(<Cordova/CDVWebViewProcessPoolFactory.h>) // Cordova-iOS >=6
|
||||
#import <Cordova/CDVWebViewProcessPoolFactory.h>
|
||||
#elif __has_include("CDVWKProcessPoolFactory.h") // Cordova-iOS <6 with WKWebView plugin
|
||||
#import "CDVWKProcessPoolFactory.h"
|
||||
#endif
|
||||
|
||||
#import <Cordova/CDVWebViewProcessPoolFactory.h>
|
||||
#import <Cordova/CDVPluginResult.h>
|
||||
|
||||
#define kInAppBrowserTargetSelf @"_self"
|
||||
@ -43,11 +37,6 @@
|
||||
|
||||
#pragma mark CDVWKInAppBrowser
|
||||
|
||||
@interface CDVWKInAppBrowser () {
|
||||
NSInteger _previousStatusBarStyle;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation CDVWKInAppBrowser
|
||||
|
||||
static CDVWKInAppBrowser* instance = nil;
|
||||
@ -59,7 +48,6 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
- (void)pluginInitialize
|
||||
{
|
||||
instance = self;
|
||||
_previousStatusBarStyle = -1;
|
||||
_callbackIdPattern = nil;
|
||||
_beforeload = @"";
|
||||
_waitForBeforeload = NO;
|
||||
@ -140,64 +128,27 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
}
|
||||
|
||||
if (browserOptions.clearcache) {
|
||||
bool isAtLeastiOS11 = false;
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
|
||||
if (@available(iOS 11.0, *)) {
|
||||
isAtLeastiOS11 = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(isAtLeastiOS11){
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
|
||||
// Deletes all cookies
|
||||
WKHTTPCookieStore* cookieStore = dataStore.httpCookieStore;
|
||||
[cookieStore getAllCookies:^(NSArray* cookies) {
|
||||
NSHTTPCookie* cookie;
|
||||
for(cookie in cookies){
|
||||
[cookieStore deleteCookie:cookie completionHandler:nil];
|
||||
}
|
||||
}];
|
||||
#endif
|
||||
}else{
|
||||
// https://stackoverflow.com/a/31803708/777265
|
||||
// Only deletes domain cookies (not session cookies)
|
||||
[dataStore fetchDataRecordsOfTypes:[WKWebsiteDataStore allWebsiteDataTypes]
|
||||
completionHandler:^(NSArray<WKWebsiteDataRecord *> * __nonnull records) {
|
||||
for (WKWebsiteDataRecord *record in records){
|
||||
NSSet<NSString*>* dataTypes = record.dataTypes;
|
||||
if([dataTypes containsObject:WKWebsiteDataTypeCookies]){
|
||||
[[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:record.dataTypes
|
||||
forDataRecords:@[record]
|
||||
completionHandler:^{}];
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
// Deletes all cookies
|
||||
WKHTTPCookieStore* cookieStore = dataStore.httpCookieStore;
|
||||
[cookieStore getAllCookies:^(NSArray* cookies) {
|
||||
NSHTTPCookie* cookie;
|
||||
for(cookie in cookies){
|
||||
[cookieStore deleteCookie:cookie completionHandler:nil];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
if (browserOptions.clearsessioncache) {
|
||||
bool isAtLeastiOS11 = false;
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
|
||||
if (@available(iOS 11.0, *)) {
|
||||
isAtLeastiOS11 = true;
|
||||
}
|
||||
#endif
|
||||
if (isAtLeastiOS11) {
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
|
||||
// Deletes session cookies
|
||||
WKHTTPCookieStore* cookieStore = dataStore.httpCookieStore;
|
||||
[cookieStore getAllCookies:^(NSArray* cookies) {
|
||||
NSHTTPCookie* cookie;
|
||||
for(cookie in cookies){
|
||||
if(cookie.sessionOnly){
|
||||
[cookieStore deleteCookie:cookie completionHandler:nil];
|
||||
}
|
||||
// Deletes session cookies
|
||||
WKHTTPCookieStore* cookieStore = dataStore.httpCookieStore;
|
||||
[cookieStore getAllCookies:^(NSArray* cookies) {
|
||||
NSHTTPCookie* cookie;
|
||||
for(cookie in cookies){
|
||||
if(cookie.sessionOnly){
|
||||
[cookieStore deleteCookie:cookie completionHandler:nil];
|
||||
}
|
||||
}];
|
||||
#endif
|
||||
}else{
|
||||
NSLog(@"clearsessioncache not available below iOS 11.0");
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
if (self.inAppBrowserViewController == nil) {
|
||||
@ -279,14 +230,6 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
NSLog(@"Tried to show IAB after it was closed.");
|
||||
return;
|
||||
}
|
||||
if (_previousStatusBarStyle != -1) {
|
||||
NSLog(@"Tried to show IAB while already shown");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!initHidden){
|
||||
_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
|
||||
}
|
||||
|
||||
__block CDVInAppBrowserNavigationController* nav = [[CDVInAppBrowserNavigationController alloc]
|
||||
initWithRootViewController:self.inAppBrowserViewController];
|
||||
@ -334,17 +277,10 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
|
||||
|
||||
}
|
||||
if (_previousStatusBarStyle == -1) {
|
||||
NSLog(@"Tried to hide IAB while already hidden");
|
||||
return;
|
||||
}
|
||||
|
||||
_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
|
||||
|
||||
// Run later to avoid the "took a long time" log message.
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.inAppBrowserViewController != nil) {
|
||||
_previousStatusBarStyle = -1;
|
||||
[self.inAppBrowserViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
});
|
||||
@ -354,16 +290,17 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
{
|
||||
NSURLRequest* request = [NSURLRequest requestWithURL:url];
|
||||
// the webview engine itself will filter for this according to <allow-navigation> policy
|
||||
// in config.xml for cordova-ios-4.0
|
||||
// in config.xml
|
||||
[self.webViewEngine loadRequest:request];
|
||||
}
|
||||
|
||||
- (void)openInSystem:(NSURL*)url
|
||||
{
|
||||
if ([[UIApplication sharedApplication] openURL:url] == NO) {
|
||||
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
|
||||
[[UIApplication sharedApplication] openURL:url];
|
||||
}
|
||||
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
|
||||
if (!success) {
|
||||
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)loadAfterBeforeload:(CDVInvokedUrlCommand*)command
|
||||
@ -682,15 +619,6 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
// Based on https://stackoverflow.com/questions/4544489/how-to-remove-a-uiwindow
|
||||
self->tmpWindow.hidden = YES;
|
||||
self->tmpWindow = nil;
|
||||
|
||||
if (IsAtLeastiOSVersion(@"7.0")) {
|
||||
if (_previousStatusBarStyle != -1) {
|
||||
[[UIApplication sharedApplication] setStatusBarStyle:_previousStatusBarStyle];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
_previousStatusBarStyle = -1; // this value was reset before reapplying it. caused statusbar to stay black on ios7
|
||||
}
|
||||
|
||||
@end //CDVWKInAppBrowser
|
||||
@ -752,15 +680,11 @@ BOOL isExiting = FALSE;
|
||||
|
||||
//WKWebView options
|
||||
configuration.allowsInlineMediaPlayback = _browserOptions.allowinlinemediaplayback;
|
||||
if (IsAtLeastiOSVersion(@"10.0")) {
|
||||
configuration.ignoresViewportScaleLimits = _browserOptions.enableviewportscale;
|
||||
if(_browserOptions.mediaplaybackrequiresuseraction == YES){
|
||||
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll;
|
||||
}else{
|
||||
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
|
||||
}
|
||||
}else{ // iOS 9
|
||||
configuration.mediaPlaybackRequiresUserAction = _browserOptions.mediaplaybackrequiresuseraction;
|
||||
configuration.ignoresViewportScaleLimits = _browserOptions.enableviewportscale;
|
||||
if(_browserOptions.mediaplaybackrequiresuseraction == YES){
|
||||
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll;
|
||||
}else{
|
||||
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
|
||||
}
|
||||
|
||||
if (@available(iOS 13.0, *)) {
|
||||
@ -813,11 +737,7 @@ BOOL isExiting = FALSE;
|
||||
self.webView.allowsLinkPreview = NO;
|
||||
self.webView.allowsBackForwardNavigationGestures = NO;
|
||||
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
|
||||
if (@available(iOS 11.0, *)) {
|
||||
[self.webView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
|
||||
}
|
||||
#endif
|
||||
[self.webView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
|
||||
|
||||
self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
|
||||
self.spinner.alpha = 1.000;
|
||||
@ -947,7 +867,7 @@ BOOL isExiting = FALSE;
|
||||
// but, if you want to set this yourself, knock yourself out (we can't set the title for a system Done button, so we have to create a new one)
|
||||
self.closeButton = nil;
|
||||
// Initialize with title if title is set, otherwise the title will be 'Done' localized
|
||||
self.closeButton = title != nil ? [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStyleBordered target:self action:@selector(close)] : [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(close)];
|
||||
self.closeButton = title != nil ? [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:self action:@selector(close)] : [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(close)];
|
||||
self.closeButton.enabled = YES;
|
||||
// If color on closebutton is requested then initialize with that that color, otherwise use initialize with default
|
||||
self.closeButton.tintColor = colorString != nil ? [self colorFromHexString:colorString] : [UIColor colorWithRed:60.0 / 255.0 green:136.0 / 255.0 blue:230.0 / 255.0 alpha:1];
|
||||
@ -1148,13 +1068,8 @@ BOOL isExiting = FALSE;
|
||||
[super viewWillAppear:animated];
|
||||
}
|
||||
|
||||
//
|
||||
// On iOS 7 the status bar is part of the view's dimensions, therefore it's height has to be taken into account.
|
||||
// The height of it could be hardcoded as 20 pixels, but that would assume that the upcoming releases of iOS won't
|
||||
// change that value.
|
||||
//
|
||||
- (float) getStatusBarOffset {
|
||||
return (float) IsAtLeastiOSVersion(@"7.0") ? [[UIApplication sharedApplication] statusBarFrame].size.height : 0.0;
|
||||
return (float) [[UIApplication sharedApplication] statusBarFrame].size.height;
|
||||
}
|
||||
|
||||
- (void) rePositionViews {
|
||||
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#import <Cordova/CDVPlugin.h>
|
||||
|
||||
@interface CDVInAppBrowser : CDVPlugin {
|
||||
}
|
||||
|
||||
@property (nonatomic, copy) NSString* callbackId;
|
||||
|
||||
- (void)open:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@end
|
||||
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#import "CDVInAppBrowser.h"
|
||||
#import <Cordova/CDVPluginResult.h>
|
||||
|
||||
#define kInAppBrowserTargetSelf @"_self"
|
||||
#define kInAppBrowserTargetSystem @"_system"
|
||||
#define kInAppBrowserTargetBlank @"_blank"
|
||||
|
||||
@interface CDVInAppBrowser () {
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation CDVInAppBrowser
|
||||
|
||||
- (void)pluginInitialize
|
||||
{
|
||||
}
|
||||
|
||||
- (BOOL) isSystemUrl:(NSURL*)url
|
||||
{
|
||||
if ([[url host] isEqualToString:@"itunes.apple.com"]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)open:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
CDVPluginResult* pluginResult;
|
||||
|
||||
NSString* url = [command argumentAtIndex:0];
|
||||
NSString* target = [command argumentAtIndex:1 withDefault:kInAppBrowserTargetSelf];
|
||||
|
||||
self.callbackId = command.callbackId;
|
||||
|
||||
if (url != nil) {
|
||||
|
||||
NSURL* baseUrl = [NSURL URLWithString:url];
|
||||
|
||||
NSURL* absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] absoluteURL];
|
||||
|
||||
if ([self isSystemUrl:absoluteUrl]) {
|
||||
target = kInAppBrowserTargetSystem;
|
||||
}
|
||||
|
||||
if ([target isEqualToString:kInAppBrowserTargetSelf]) {
|
||||
//[self openInCordovaWebView:absoluteUrl withOptions:options];
|
||||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Not Yet Implemented for OSX: [self openInCordovaWebView:absoluteUrl withOptions:options]"];
|
||||
} else if ([target isEqualToString:kInAppBrowserTargetSystem]) {
|
||||
[self openInSystem:absoluteUrl];
|
||||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||
} else { // _blank or anything else
|
||||
//[self openInInAppBrowser:absoluteUrl withOptions:options];
|
||||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Not Yet Implemented for OSX: [self openInInAppBrowser:absoluteUrl withOptions:options]"];
|
||||
}
|
||||
|
||||
} else {
|
||||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"incorrect number of arguments"];
|
||||
}
|
||||
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||
}
|
||||
|
||||
- (void)openInSystem:(NSURL*)url
|
||||
{
|
||||
[[NSWorkspace sharedWorkspace] openURL:url];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -1,407 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* eslint-disable standard/no-callback-literal */
|
||||
/* global Windows, setImmediate */
|
||||
|
||||
var cordova = require('cordova');
|
||||
var urlutil = require('cordova/urlutil');
|
||||
|
||||
var browserWrap,
|
||||
popup,
|
||||
navigationButtonsDiv,
|
||||
navigationButtonsDivInner,
|
||||
backButton,
|
||||
forwardButton,
|
||||
closeButton,
|
||||
bodyOverflowStyle,
|
||||
navigationEventsCallback,
|
||||
hardwareBackCallback;
|
||||
|
||||
// x-ms-webview is available starting from Windows 8.1 (platformId is 'windows')
|
||||
// http://msdn.microsoft.com/en-us/library/windows/apps/dn301831.aspx
|
||||
var isWebViewAvailable = cordova.platformId === 'windows';
|
||||
|
||||
function attachNavigationEvents (element, callback) {
|
||||
if (isWebViewAvailable) {
|
||||
element.addEventListener('MSWebViewNavigationStarting', function (e) {
|
||||
callback({ type: 'loadstart', url: e.uri }, { keepCallback: true });
|
||||
});
|
||||
|
||||
element.addEventListener('MSWebViewNavigationCompleted', function (e) {
|
||||
if (e.isSuccess) {
|
||||
callback({ type: 'loadstop', url: e.uri }, { keepCallback: true });
|
||||
} else {
|
||||
callback(
|
||||
{
|
||||
type: 'loaderror',
|
||||
url: e.uri,
|
||||
code: e.webErrorStatus,
|
||||
message: 'Navigation failed with error code ' + e.webErrorStatus
|
||||
},
|
||||
{ keepCallback: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
element.addEventListener('MSWebViewUnviewableContentIdentified', function (e) {
|
||||
// WebView found the content to be not HTML.
|
||||
// http://msdn.microsoft.com/en-us/library/windows/apps/dn609716.aspx
|
||||
callback(
|
||||
{ type: 'loaderror', url: e.uri, code: e.webErrorStatus, message: 'Navigation failed with error code ' + e.webErrorStatus },
|
||||
{ keepCallback: true }
|
||||
);
|
||||
});
|
||||
|
||||
element.addEventListener('MSWebViewContentLoading', function (e) {
|
||||
if (navigationButtonsDiv && popup) {
|
||||
if (popup.canGoBack) {
|
||||
backButton.removeAttribute('disabled');
|
||||
} else {
|
||||
backButton.setAttribute('disabled', 'true');
|
||||
}
|
||||
|
||||
if (popup.canGoForward) {
|
||||
forwardButton.removeAttribute('disabled');
|
||||
} else {
|
||||
forwardButton.setAttribute('disabled', 'true');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var onError = function () {
|
||||
callback({ type: 'loaderror', url: this.contentWindow.location }, { keepCallback: true });
|
||||
};
|
||||
|
||||
element.addEventListener('unload', function () {
|
||||
callback({ type: 'loadstart', url: this.contentWindow.location }, { keepCallback: true });
|
||||
});
|
||||
|
||||
element.addEventListener('load', function () {
|
||||
callback({ type: 'loadstop', url: this.contentWindow.location }, { keepCallback: true });
|
||||
});
|
||||
|
||||
element.addEventListener('error', onError);
|
||||
element.addEventListener('abort', onError);
|
||||
}
|
||||
}
|
||||
|
||||
var IAB = {
|
||||
close: function (win, lose) {
|
||||
setImmediate(function () {
|
||||
if (browserWrap) {
|
||||
if (navigationEventsCallback) {
|
||||
navigationEventsCallback({ type: 'exit' });
|
||||
}
|
||||
|
||||
browserWrap.parentNode.removeChild(browserWrap);
|
||||
// Reset body overflow style to initial value
|
||||
document.body.style.msOverflowStyle = bodyOverflowStyle;
|
||||
browserWrap = null;
|
||||
popup = null;
|
||||
|
||||
document.removeEventListener('backbutton', hardwareBackCallback, false);
|
||||
}
|
||||
});
|
||||
},
|
||||
show: function (win, lose) {
|
||||
setImmediate(function () {
|
||||
if (browserWrap) {
|
||||
browserWrap.style.display = 'block';
|
||||
}
|
||||
});
|
||||
},
|
||||
hide: function (win, lose) {
|
||||
if (browserWrap) {
|
||||
browserWrap.style.display = 'none';
|
||||
}
|
||||
},
|
||||
open: function (win, lose, args) {
|
||||
// make function async so that we can add navigation events handlers before view is loaded and navigation occured
|
||||
setImmediate(function () {
|
||||
var strUrl = args[0];
|
||||
var target = args[1];
|
||||
var features = args[2];
|
||||
var url;
|
||||
|
||||
navigationEventsCallback = win;
|
||||
|
||||
if (target === '_system') {
|
||||
url = new Windows.Foundation.Uri(strUrl);
|
||||
Windows.System.Launcher.launchUriAsync(url);
|
||||
} else if (target === '_self' || !target) {
|
||||
window.location = strUrl;
|
||||
} else {
|
||||
// "_blank" or anything else
|
||||
if (!browserWrap) {
|
||||
var browserWrapStyle = document.createElement('link');
|
||||
browserWrapStyle.rel = 'stylesheet';
|
||||
browserWrapStyle.type = 'text/css';
|
||||
browserWrapStyle.href = urlutil.makeAbsolute('/www/css/inappbrowser.css');
|
||||
|
||||
document.head.appendChild(browserWrapStyle);
|
||||
|
||||
browserWrap = document.createElement('div');
|
||||
browserWrap.className = 'inAppBrowserWrap';
|
||||
|
||||
if (features.indexOf('fullscreen=yes') > -1) {
|
||||
browserWrap.classList.add('inAppBrowserWrapFullscreen');
|
||||
}
|
||||
|
||||
// Save body overflow style to be able to reset it back later
|
||||
bodyOverflowStyle = document.body.style.msOverflowStyle;
|
||||
|
||||
browserWrap.onclick = function () {
|
||||
setTimeout(function () {
|
||||
IAB.close(navigationEventsCallback);
|
||||
}, 0);
|
||||
};
|
||||
|
||||
document.body.appendChild(browserWrap);
|
||||
// Hide scrollbars for the whole body while inappbrowser's window is open
|
||||
document.body.style.msOverflowStyle = 'none';
|
||||
}
|
||||
|
||||
if (features.indexOf('hidden=yes') !== -1) {
|
||||
browserWrap.style.display = 'none';
|
||||
}
|
||||
|
||||
popup = document.createElement(isWebViewAvailable ? 'x-ms-webview' : 'iframe');
|
||||
if (popup instanceof HTMLIFrameElement) {
|
||||
// eslint-disable-line no-undef
|
||||
// For iframe we need to override bacground color of parent element here
|
||||
// otherwise pages without background color set will have transparent background
|
||||
popup.style.backgroundColor = 'white';
|
||||
}
|
||||
popup.style.borderWidth = '0px';
|
||||
popup.style.width = '100%';
|
||||
popup.style.marginBottom = '-5px';
|
||||
|
||||
browserWrap.appendChild(popup);
|
||||
|
||||
var closeHandler = function (e) {
|
||||
setTimeout(function () {
|
||||
IAB.close(navigationEventsCallback);
|
||||
}, 0);
|
||||
};
|
||||
|
||||
if (features.indexOf('hardwareback=yes') > -1 || features.indexOf('hardwareback') === -1) {
|
||||
hardwareBackCallback = function () {
|
||||
if (browserWrap.style.display === 'none') {
|
||||
// NOTE: backbutton handlers have to throw an exception in order to prevent
|
||||
// returning 'true' inside cordova-js, which would mean that the event is handled by user.
|
||||
// Throwing an exception means that the default/system navigation behavior will take place,
|
||||
// which is to exit the app if the navigation stack is empty.
|
||||
throw 'Exit the app'; // eslint-disable-line no-throw-literal
|
||||
}
|
||||
|
||||
if (popup.canGoBack) {
|
||||
popup.goBack();
|
||||
} else {
|
||||
closeHandler();
|
||||
}
|
||||
};
|
||||
} else if (features.indexOf('hardwareback=no') > -1) {
|
||||
hardwareBackCallback = function () {
|
||||
if (browserWrap.style.display === 'none') {
|
||||
// See comment above
|
||||
throw 'Exit the app'; // eslint-disable-line no-throw-literal
|
||||
}
|
||||
|
||||
closeHandler();
|
||||
};
|
||||
}
|
||||
|
||||
document.addEventListener('backbutton', hardwareBackCallback, false);
|
||||
|
||||
if (features.indexOf('location=yes') !== -1 || features.indexOf('location') === -1) {
|
||||
popup.style.height = 'calc(100% - 70px)';
|
||||
|
||||
navigationButtonsDiv = document.createElement('div');
|
||||
navigationButtonsDiv.className = 'inappbrowser-app-bar';
|
||||
navigationButtonsDiv.onclick = function (e) {
|
||||
e.cancelBubble = true;
|
||||
};
|
||||
|
||||
navigationButtonsDivInner = document.createElement('div');
|
||||
navigationButtonsDivInner.className = 'inappbrowser-app-bar-inner';
|
||||
navigationButtonsDivInner.onclick = function (e) {
|
||||
e.cancelBubble = true;
|
||||
};
|
||||
|
||||
backButton = document.createElement('div');
|
||||
backButton.innerText = 'back';
|
||||
backButton.className = 'app-bar-action action-back';
|
||||
backButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoBack) {
|
||||
popup.goBack();
|
||||
}
|
||||
});
|
||||
|
||||
forwardButton = document.createElement('div');
|
||||
forwardButton.innerText = 'forward';
|
||||
forwardButton.className = 'app-bar-action action-forward';
|
||||
forwardButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoForward) {
|
||||
popup.goForward();
|
||||
}
|
||||
});
|
||||
|
||||
closeButton = document.createElement('div');
|
||||
closeButton.innerText = 'close';
|
||||
closeButton.className = 'app-bar-action action-close';
|
||||
closeButton.addEventListener('click', closeHandler);
|
||||
|
||||
if (!isWebViewAvailable) {
|
||||
// iframe navigation is not yet supported
|
||||
backButton.setAttribute('disabled', 'true');
|
||||
forwardButton.setAttribute('disabled', 'true');
|
||||
}
|
||||
|
||||
navigationButtonsDivInner.appendChild(backButton);
|
||||
navigationButtonsDivInner.appendChild(forwardButton);
|
||||
navigationButtonsDivInner.appendChild(closeButton);
|
||||
navigationButtonsDiv.appendChild(navigationButtonsDivInner);
|
||||
|
||||
browserWrap.appendChild(navigationButtonsDiv);
|
||||
} else {
|
||||
popup.style.height = '100%';
|
||||
}
|
||||
|
||||
// start listening for navigation events
|
||||
attachNavigationEvents(popup, navigationEventsCallback);
|
||||
|
||||
if (isWebViewAvailable) {
|
||||
strUrl = strUrl.replace('ms-appx://', 'ms-appx-web://');
|
||||
}
|
||||
popup.src = strUrl;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
injectScriptCode: function (win, fail, args) {
|
||||
setImmediate(function () {
|
||||
var code = args[0];
|
||||
var hasCallback = args[1];
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
var op = popup.invokeScriptAsync('eval', code);
|
||||
op.oncomplete = function (e) {
|
||||
if (hasCallback) {
|
||||
// return null if event target is unavailable by some reason
|
||||
var result = e && e.target ? [e.target.result] : [null];
|
||||
win(result);
|
||||
}
|
||||
};
|
||||
op.onerror = function () {};
|
||||
op.start();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
injectScriptFile: function (win, fail, args) {
|
||||
setImmediate(function () {
|
||||
var filePath = args[0];
|
||||
var hasCallback = args[1];
|
||||
|
||||
if (filePath) {
|
||||
filePath = urlutil.makeAbsolute(filePath);
|
||||
}
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
// CB-12364 getFileFromApplicationUriAsync does not support ms-appx-web
|
||||
var uri = new Windows.Foundation.Uri(filePath.replace('ms-appx-web:', 'ms-appx:'));
|
||||
Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).done(function (file) {
|
||||
Windows.Storage.FileIO.readTextAsync(file).done(function (code) {
|
||||
var op = popup.invokeScriptAsync('eval', code);
|
||||
op.oncomplete = function (e) {
|
||||
if (hasCallback) {
|
||||
var result = [e.target.result];
|
||||
win(result);
|
||||
}
|
||||
};
|
||||
op.onerror = function () {};
|
||||
op.start();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
injectStyleCode: function (win, fail, args) {
|
||||
setImmediate(function () {
|
||||
var code = args[0];
|
||||
var hasCallback = args[1];
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
injectCSS(popup, code, hasCallback && win);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
injectStyleFile: function (win, fail, args) {
|
||||
setImmediate(function () {
|
||||
var filePath = args[0];
|
||||
var hasCallback = args[1];
|
||||
|
||||
filePath = filePath && urlutil.makeAbsolute(filePath);
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
// CB-12364 getFileFromApplicationUriAsync does not support ms-appx-web
|
||||
var uri = new Windows.Foundation.Uri(filePath.replace('ms-appx-web:', 'ms-appx:'));
|
||||
Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri)
|
||||
.then(function (file) {
|
||||
return Windows.Storage.FileIO.readTextAsync(file);
|
||||
})
|
||||
.done(
|
||||
function (code) {
|
||||
injectCSS(popup, code, hasCallback && win);
|
||||
},
|
||||
function () {
|
||||
// no-op, just catch an error
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function injectCSS (webView, cssCode, callback) {
|
||||
// This will automatically escape all thing that we need (quotes, slashes, etc.)
|
||||
var escapedCode = JSON.stringify(cssCode);
|
||||
var evalWrapper = "(function(d){var c=d.createElement('style');c.innerHTML=%s;d.head.appendChild(c);})(document)".replace(
|
||||
'%s',
|
||||
escapedCode
|
||||
);
|
||||
|
||||
var op = webView.invokeScriptAsync('eval', evalWrapper);
|
||||
op.oncomplete = function () {
|
||||
if (callback) {
|
||||
callback([]);
|
||||
}
|
||||
};
|
||||
op.onerror = function () {};
|
||||
op.start();
|
||||
}
|
||||
|
||||
module.exports = IAB;
|
||||
|
||||
require('cordova/exec/proxy').add('InAppBrowser', module.exports);
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cordova-plugin-inappbrowser-tests",
|
||||
"version": "5.1.0-dev",
|
||||
"version": "6.0.1-dev",
|
||||
"description": "",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-inappbrowser-tests",
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-inappbrowser-tests"
|
||||
version="5.1.0-dev">
|
||||
version="6.0.1-dev">
|
||||
<name>Cordova InAppBrowser Plugin Tests</name>
|
||||
<license>Apache 2.0</license>
|
||||
|
||||
|
@ -17,5 +17,5 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
var d = document.getElementById('header');
|
||||
const d = document.getElementById('header');
|
||||
d.innerHTML = 'Script file successfully injected';
|
||||
|
169
tests/tests.js
169
tests/tests.js
@ -19,22 +19,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* global MSApp */
|
||||
|
||||
var cordova = require('cordova');
|
||||
var isWindows = cordova.platformId === 'windows';
|
||||
var isIos = cordova.platformId === 'ios';
|
||||
var isAndroid = cordova.platformId === 'android';
|
||||
var isBrowser = cordova.platformId === 'browser';
|
||||
const cordova = require('cordova');
|
||||
const isIos = cordova.platformId === 'ios';
|
||||
const isAndroid = cordova.platformId === 'android';
|
||||
const isBrowser = cordova.platformId === 'browser';
|
||||
|
||||
window.alert = window.alert || navigator.notification.alert;
|
||||
if (isWindows && navigator && navigator.notification && navigator.notification.alert) {
|
||||
// window.alert is defined but not functional on UWP
|
||||
window.alert = navigator.notification.alert;
|
||||
}
|
||||
|
||||
exports.defineAutoTests = function () {
|
||||
var createTests = function (platformOpts) {
|
||||
const createTests = function (platformOpts) {
|
||||
platformOpts = platformOpts || '';
|
||||
|
||||
describe('cordova.InAppBrowser', function () {
|
||||
@ -54,10 +47,10 @@ exports.defineAutoTests = function () {
|
||||
return;
|
||||
}
|
||||
|
||||
var iabInstance;
|
||||
var originalTimeout;
|
||||
var url = 'https://dist.apache.org/repos/dist/dev/cordova/';
|
||||
var badUrl = 'http://bad-uri/';
|
||||
let iabInstance;
|
||||
let originalTimeout;
|
||||
const url = 'https://dist.apache.org/repos/dist/dev/cordova/';
|
||||
const badUrl = 'http://bad-uri/';
|
||||
|
||||
beforeEach(function () {
|
||||
// increase timeout to ensure test url could be loaded within test time
|
||||
@ -111,7 +104,7 @@ exports.defineAutoTests = function () {
|
||||
});
|
||||
|
||||
it('inappbrowser.spec.4 should support loadstart and loadstop events', function (done) {
|
||||
var onLoadStart = jasmine.createSpy('loadstart event callback').and.callFake(function (evt) {
|
||||
const onLoadStart = jasmine.createSpy('loadstart event callback').and.callFake(function (evt) {
|
||||
verifyEvent(evt, 'loadstart');
|
||||
});
|
||||
|
||||
@ -157,8 +150,8 @@ exports.defineAutoTests = function () {
|
||||
if (!isAndroid && !isIos) {
|
||||
return pending(cordova.platformId + " platform doesn't support message event");
|
||||
}
|
||||
var messageKey = 'my_message';
|
||||
var messageValue = 'is_this';
|
||||
const messageKey = 'my_message';
|
||||
const messageValue = 'is_this';
|
||||
iabInstance = cordova.InAppBrowser.open(url, '_blank', platformOpts);
|
||||
iabInstance.addEventListener('message', function (evt) {
|
||||
// Verify message event
|
||||
@ -170,7 +163,7 @@ exports.defineAutoTests = function () {
|
||||
done();
|
||||
});
|
||||
iabInstance.addEventListener('loadstop', function (evt) {
|
||||
var code =
|
||||
const code =
|
||||
'(function(){\n' +
|
||||
' var message = {' +
|
||||
messageKey +
|
||||
@ -179,7 +172,7 @@ exports.defineAutoTests = function () {
|
||||
'"};\n' +
|
||||
' webkit.messageHandlers.cordova_iab.postMessage(JSON.stringify(message));\n' +
|
||||
'})()';
|
||||
iabInstance.executeScript({ code: code });
|
||||
iabInstance.executeScript({ code });
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -188,17 +181,17 @@ exports.defineAutoTests = function () {
|
||||
};
|
||||
|
||||
exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
var platformOpts = '';
|
||||
var platform_info = '';
|
||||
const platformOpts = '';
|
||||
const platform_info = '';
|
||||
|
||||
function doOpen (url, target, params, numExpectedRedirects, useWindowOpen) {
|
||||
numExpectedRedirects = numExpectedRedirects || 0;
|
||||
useWindowOpen = useWindowOpen || false;
|
||||
console.log('Opening ' + url);
|
||||
|
||||
var counts;
|
||||
var lastLoadStartURL;
|
||||
var wasReset = false;
|
||||
let counts;
|
||||
let lastLoadStartURL;
|
||||
let wasReset = false;
|
||||
function reset () {
|
||||
counts = {
|
||||
loaderror: 0,
|
||||
@ -210,8 +203,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
}
|
||||
reset();
|
||||
|
||||
var iab;
|
||||
var callbacks = {
|
||||
let iab;
|
||||
const callbacks = {
|
||||
loaderror: logEvent,
|
||||
loadstart: logEvent,
|
||||
loadstop: logEvent,
|
||||
@ -265,7 +258,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
}
|
||||
// Verify that loadend / loaderror was called.
|
||||
if (e.type === 'exit') {
|
||||
var numStopEvents = counts.loadstop + counts.loaderror;
|
||||
const numStopEvents = counts.loadstop + counts.loaderror;
|
||||
if (numStopEvents === 0 && !wasReset) {
|
||||
alert('Unexpected: browser closed without a loadstop or loaderror.'); // eslint-disable-line no-undef
|
||||
} else if (numStopEvents > 1) {
|
||||
@ -278,8 +271,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
}
|
||||
|
||||
function doHookOpen (url, target, params, numExpectedRedirects) {
|
||||
var originalFunc = window.open;
|
||||
var wasClobbered = Object.prototype.hasOwnProperty.call(window, 'open');
|
||||
const originalFunc = window.open;
|
||||
const wasClobbered = Object.prototype.hasOwnProperty.call(window, 'open');
|
||||
window.open = cordova.InAppBrowser.open;
|
||||
|
||||
try {
|
||||
@ -295,8 +288,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
}
|
||||
|
||||
function openWithStyle (url, cssUrl, useCallback) {
|
||||
var iab = doOpen(url, '_blank', 'location=yes');
|
||||
var callback = function (results) {
|
||||
const iab = doOpen(url, '_blank', 'location=yes');
|
||||
const callback = function (results) {
|
||||
if (results && results.length === 0) {
|
||||
alert('Results verified'); // eslint-disable-line no-undef
|
||||
} else {
|
||||
@ -316,7 +309,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
}
|
||||
|
||||
function openWithScript (url, jsUrl, useCallback) {
|
||||
var iab = doOpen(url, '_blank', 'location=yes');
|
||||
const iab = doOpen(url, '_blank', 'location=yes');
|
||||
if (jsUrl) {
|
||||
iab.addEventListener('loadstop', function (event) {
|
||||
iab.executeScript(
|
||||
@ -334,14 +327,14 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
});
|
||||
} else {
|
||||
iab.addEventListener('loadstop', function (event) {
|
||||
var code =
|
||||
const code =
|
||||
'(function(){\n' +
|
||||
' var header = document.getElementById("header");\n' +
|
||||
' header.innerHTML = "Script literal successfully injected";\n' +
|
||||
' return "abc";\n' +
|
||||
'})()';
|
||||
iab.executeScript(
|
||||
{ code: code },
|
||||
{ code },
|
||||
useCallback &&
|
||||
function (results) {
|
||||
if (results && results.length === 1 && results[0] === 'abc') {
|
||||
@ -355,12 +348,12 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
});
|
||||
}
|
||||
}
|
||||
var hiddenwnd = null;
|
||||
var loadlistener = function (event) {
|
||||
let hiddenwnd = null;
|
||||
const loadlistener = function (event) {
|
||||
alert('background window loaded ');
|
||||
}; // eslint-disable-line no-undef
|
||||
function openHidden (url, startHidden) {
|
||||
var shopt = startHidden ? 'hidden=yes' : '';
|
||||
let shopt = startHidden ? 'hidden=yes' : '';
|
||||
if (platformOpts) {
|
||||
shopt += (shopt ? ',' : '') + platformOpts;
|
||||
}
|
||||
@ -384,7 +377,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
}
|
||||
}
|
||||
|
||||
var info_div =
|
||||
const info_div =
|
||||
'<h1>InAppBrowser</h1>' +
|
||||
'<div id="info">' +
|
||||
'Make sure http://cordova.apache.org and http://google.co.uk and https://www.google.co.uk are white listed. </br>' +
|
||||
@ -393,7 +386,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<h4>User-Agent: <span id="user-agent"> </span></hr>' +
|
||||
'</div>';
|
||||
|
||||
var local_tests =
|
||||
const local_tests =
|
||||
'<h1>Local URL</h1>' +
|
||||
'<div id="openLocal"></div>' +
|
||||
'Expected result: opens successfully in CordovaWebView.' +
|
||||
@ -414,7 +407,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<p/><div id="openLocalRandomToolBarTopNoLocation"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with no locationBar. On iOS the toolbar is at the top.';
|
||||
|
||||
var white_listed_tests =
|
||||
const white_listed_tests =
|
||||
'<h1>White Listed URL</h1>' +
|
||||
'<div id="openWhiteListed"></div>' +
|
||||
'Expected result: open successfully in CordovaWebView to cordova.apache.org' +
|
||||
@ -431,7 +424,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<p/> <div id="openWhiteListedRandomNoLocation"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to cordova.apache.org with no location bar.';
|
||||
|
||||
var non_white_listed_tests =
|
||||
const non_white_listed_tests =
|
||||
'<h1>Non White Listed URL</h1>' +
|
||||
'<div id="openNonWhiteListed"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to apple.com.' +
|
||||
@ -448,21 +441,21 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<p/> <div id="openNonWhiteListedRandomNoLocation"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to apple.com without locationBar.';
|
||||
|
||||
var page_with_redirects_tests =
|
||||
const page_with_redirects_tests =
|
||||
'<h1>Page with redirect</h1>' +
|
||||
'<div id="openRedirect301"></div>' +
|
||||
'Expected result: should 301 and open successfully in InAppBrowser to https://www.google.co.uk.' +
|
||||
'<p/> <div id="openRedirect302"></div>' +
|
||||
'Expected result: should 302 and open successfully in InAppBrowser to www.zhihu.com/answer/16714076.';
|
||||
|
||||
var pdf_url_tests =
|
||||
const pdf_url_tests =
|
||||
'<h1>PDF URL</h1>' +
|
||||
'<div id="openPDF"></div>' +
|
||||
'Expected result: InAppBrowser opens. PDF should render on iOS.' +
|
||||
'<p/> <div id="openPDFBlank"></div>' +
|
||||
'Expected result: InAppBrowser opens. PDF should render on iOS.';
|
||||
|
||||
var invalid_url_tests =
|
||||
const invalid_url_tests =
|
||||
'<h1>Invalid URL</h1>' +
|
||||
'<div id="openInvalidScheme"></div>' +
|
||||
'Expected result: fail to load in InAppBrowser.' +
|
||||
@ -471,7 +464,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<p/> <div id="openInvalidMissing"></div>' +
|
||||
'Expected result: fail to load in InAppBrowser (404).';
|
||||
|
||||
var css_js_injection_tests =
|
||||
const css_js_injection_tests =
|
||||
'<h1>CSS / JS Injection</h1>' +
|
||||
'<div id="openOriginalDocument"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser without text "Style updated from..."' +
|
||||
@ -492,7 +485,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<p/> <div id="openScriptLiteralInjectionCallback"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with the text "Script literal successfully injected" and alert dialog with the text "Results verified".';
|
||||
|
||||
var open_hidden_tests =
|
||||
const open_hidden_tests =
|
||||
'<h1>Open Hidden </h1>' +
|
||||
'<div id="openHidden"></div>' +
|
||||
'Expected result: no additional browser window. Alert appears with the text "background window loaded".' +
|
||||
@ -505,14 +498,14 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<p/> <div id="openVisibleAndHide"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to https://www.google.co.uk. Hide after 2 seconds';
|
||||
|
||||
var clearing_cache_tests =
|
||||
const clearing_cache_tests =
|
||||
'<h1>Clearing Cache</h1>' +
|
||||
'<div id="openClearCache"></div>' +
|
||||
'Expected result: ?' +
|
||||
'<p/> <div id="openClearSessionCache"></div>' +
|
||||
'Expected result: ?';
|
||||
|
||||
var video_tag_tests =
|
||||
const video_tag_tests =
|
||||
'<h1>Video tag</h1>' +
|
||||
'<div id="openRemoteVideo"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with an embedded video plays automatically on iOS and Android.' +
|
||||
@ -521,14 +514,14 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<div id="openRemoteNeedUserYesVideo"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with an embedded video does not play automatically on iOS and Android but rather works after clicking the "play" button.';
|
||||
|
||||
var local_with_anchor_tag_tests =
|
||||
const local_with_anchor_tag_tests =
|
||||
'<h1>Local with anchor tag</h1>' +
|
||||
'<div id="openAnchor1"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to the local page, scrolled to the top as normal.' +
|
||||
'<p/> <div id="openAnchor2"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to the local page, scrolled to the beginning of the tall div with border.';
|
||||
|
||||
var hardwareback_tests =
|
||||
const hardwareback_tests =
|
||||
'<h1>HardwareBack</h1>' +
|
||||
'<p/> <div id="openHardwareBackDefault"></div>' +
|
||||
'Expected result: By default hardwareback is yes so pressing back button should navigate backwards in history then close InAppBrowser' +
|
||||
@ -539,54 +532,32 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<p/> <div id="openHardwareBackDefaultAfterNo"></div>' +
|
||||
'Expected result: consistently open browsers with with the appropriate option: hardwareback=defaults to yes then hardwareback=no then hardwareback=defaults to yes. By default hardwareback is yes so pressing back button should navigate backwards in history then close InAppBrowser';
|
||||
|
||||
// CB-7490 We need to wrap this code due to Windows security restrictions
|
||||
// see http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx#differences for details
|
||||
if (window.MSApp && window.MSApp.execUnsafeLocalFunction) {
|
||||
MSApp.execUnsafeLocalFunction(function () {
|
||||
contentEl.innerHTML =
|
||||
info_div +
|
||||
platform_info +
|
||||
local_tests +
|
||||
white_listed_tests +
|
||||
non_white_listed_tests +
|
||||
page_with_redirects_tests +
|
||||
pdf_url_tests +
|
||||
invalid_url_tests +
|
||||
css_js_injection_tests +
|
||||
open_hidden_tests +
|
||||
clearing_cache_tests +
|
||||
video_tag_tests +
|
||||
local_with_anchor_tag_tests +
|
||||
hardwareback_tests;
|
||||
});
|
||||
} else {
|
||||
contentEl.innerHTML =
|
||||
info_div +
|
||||
platform_info +
|
||||
local_tests +
|
||||
white_listed_tests +
|
||||
non_white_listed_tests +
|
||||
page_with_redirects_tests +
|
||||
pdf_url_tests +
|
||||
invalid_url_tests +
|
||||
css_js_injection_tests +
|
||||
open_hidden_tests +
|
||||
clearing_cache_tests +
|
||||
video_tag_tests +
|
||||
local_with_anchor_tag_tests +
|
||||
hardwareback_tests;
|
||||
}
|
||||
contentEl.innerHTML =
|
||||
info_div +
|
||||
platform_info +
|
||||
local_tests +
|
||||
white_listed_tests +
|
||||
non_white_listed_tests +
|
||||
page_with_redirects_tests +
|
||||
pdf_url_tests +
|
||||
invalid_url_tests +
|
||||
css_js_injection_tests +
|
||||
open_hidden_tests +
|
||||
clearing_cache_tests +
|
||||
video_tag_tests +
|
||||
local_with_anchor_tag_tests +
|
||||
hardwareback_tests;
|
||||
|
||||
document.getElementById('user-agent').textContent = navigator.userAgent;
|
||||
|
||||
// we are already in cdvtests directory
|
||||
var basePath = 'iab-resources/';
|
||||
var localhtml = basePath + 'local.html';
|
||||
var localpdf = basePath + 'local.pdf';
|
||||
var injecthtml = basePath + 'inject.html';
|
||||
var injectjs = isWindows ? basePath + 'inject.js' : 'inject.js';
|
||||
var injectcss = isWindows ? basePath + 'inject.css' : 'inject.css';
|
||||
var videohtml = basePath + 'video.html';
|
||||
const basePath = 'iab-resources/';
|
||||
const localhtml = basePath + 'local.html';
|
||||
const localpdf = basePath + 'local.pdf';
|
||||
const injecthtml = basePath + 'inject.html';
|
||||
const injectjs = 'inject.js';
|
||||
const injectcss = 'inject.css';
|
||||
const videohtml = basePath + 'video.html';
|
||||
|
||||
// Local
|
||||
createActionButton(
|
||||
@ -907,7 +878,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
createActionButton(
|
||||
'google.co.uk shown for 2 seconds than hidden',
|
||||
function () {
|
||||
var iab = doOpen('https://www.google.co.uk/', 'random_sting');
|
||||
const iab = doOpen('https://www.google.co.uk/', 'random_sting');
|
||||
setTimeout(function () {
|
||||
iab.hide();
|
||||
}, 2000);
|
||||
@ -995,12 +966,12 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
createActionButton(
|
||||
'no hardwareback -> hardwareback=no -> no hardwareback',
|
||||
function () {
|
||||
var ref = cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes' + (platformOpts ? ',' + platformOpts : ''));
|
||||
const ref = cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes' + (platformOpts ? ',' + platformOpts : ''));
|
||||
ref.addEventListener('loadstop', function () {
|
||||
ref.close();
|
||||
});
|
||||
ref.addEventListener('exit', function () {
|
||||
var ref2 = cordova.InAppBrowser.open(
|
||||
const ref2 = cordova.InAppBrowser.open(
|
||||
'https://google.com',
|
||||
'_blank',
|
||||
'location=yes,hardwareback=no' + (platformOpts ? ',' + platformOpts : '')
|
||||
|
@ -1,114 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
.inAppBrowserWrap {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
outline: 0;
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
background: 0 0;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 9999999;
|
||||
box-sizing: border-box;
|
||||
border: 40px solid #bfbfbf;
|
||||
border: 40px solid rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.inAppBrowserWrapFullscreen {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.inappbrowser-app-bar {
|
||||
height: 70px;
|
||||
background-color: #404040;
|
||||
z-index: 9999999;
|
||||
}
|
||||
|
||||
.inappbrowser-app-bar-inner {
|
||||
padding-top: 10px;
|
||||
height: 60px;
|
||||
width: 155px;
|
||||
margin: 0 auto;
|
||||
background-color: #404040;
|
||||
z-index: 9999999;
|
||||
}
|
||||
|
||||
.app-bar-action {
|
||||
width: auto;
|
||||
height: 40px;
|
||||
margin-left: 20px;
|
||||
font-family: "Segoe UI Symbol";
|
||||
float: left;
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
text-transform: lowercase;
|
||||
text-align: center;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.app-bar-action[disabled] {
|
||||
color: gray;
|
||||
/*disable click*/
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.app-bar-action::before {
|
||||
font-size: 28px;
|
||||
display: block;
|
||||
height: 36px;
|
||||
}
|
||||
|
||||
/* Back */
|
||||
.action-back {
|
||||
margin-left: 0px;
|
||||
}
|
||||
|
||||
.action-back::before {
|
||||
content: "\E0BA";
|
||||
}
|
||||
|
||||
.action-back:not([disabled]):hover::before {
|
||||
content: "\E0B3";
|
||||
}
|
||||
|
||||
/* Forward */
|
||||
.action-forward::before {
|
||||
content: "\E0AC";
|
||||
}
|
||||
|
||||
.action-forward:not([disabled]):hover::before {
|
||||
content: "\E0AF";
|
||||
}
|
||||
|
||||
/* Close */
|
||||
.action-close::before {
|
||||
content: "\E0C7";
|
||||
/* close icon is larger so we re-size it to fit other icons */
|
||||
font-size: 20px;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.action-close:not([disabled]):hover::before {
|
||||
content: "\E0CA";
|
||||
}
|
@ -20,10 +20,10 @@
|
||||
*/
|
||||
|
||||
(function () {
|
||||
var exec = require('cordova/exec');
|
||||
var channel = require('cordova/channel');
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
var urlutil = require('cordova/urlutil');
|
||||
const exec = require('cordova/exec');
|
||||
const channel = require('cordova/channel');
|
||||
const modulemapper = require('cordova/modulemapper');
|
||||
const urlutil = require('cordova/urlutil');
|
||||
|
||||
function InAppBrowser () {
|
||||
this.channels = {
|
||||
@ -100,19 +100,19 @@
|
||||
module.exports = function (strUrl, strWindowName, strWindowFeatures, callbacks) {
|
||||
// Don't catch calls that write to existing frames (e.g. named iframes).
|
||||
if (window.frames && window.frames[strWindowName]) {
|
||||
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
|
||||
const origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
|
||||
return origOpenFunc.apply(window, arguments);
|
||||
}
|
||||
|
||||
strUrl = urlutil.makeAbsolute(strUrl);
|
||||
var iab = new InAppBrowser();
|
||||
const iab = new InAppBrowser();
|
||||
|
||||
callbacks = callbacks || {};
|
||||
for (var callbackName in callbacks) {
|
||||
for (const callbackName in callbacks) {
|
||||
iab.addEventListener(callbackName, callbacks[callbackName]);
|
||||
}
|
||||
|
||||
var cb = function (eventname) {
|
||||
const cb = function (eventname) {
|
||||
iab._eventHandler(eventname);
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user