mirror of
https://github.com/shuto-cn/cordova-plugin-inappbrowser.git
synced 2026-01-26 00:00:04 +08:00
Compare commits
55 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9c577044c | ||
|
|
cc2299e1c3 | ||
|
|
7fb19f6bdc | ||
|
|
71201b10a6 | ||
|
|
50ac05ca41 | ||
|
|
dcc00fc3bd | ||
|
|
e9878ddecd | ||
|
|
aee699a0e5 | ||
|
|
d78cfdc4d4 | ||
|
|
bf6945feb0 | ||
|
|
ad4a0a3120 | ||
|
|
3882924c4a | ||
|
|
6eb9bbbf75 | ||
|
|
7ac56842aa | ||
|
|
dbf3316df3 | ||
|
|
171e7dfea7 | ||
|
|
6ea100a9fe | ||
|
|
bfe8763918 | ||
|
|
902427525f | ||
|
|
7611645469 | ||
|
|
72ac4d7eca | ||
|
|
32d867f8e4 | ||
|
|
6e058624d6 | ||
|
|
ed139eeb34 | ||
|
|
aa82a5d6c8 | ||
|
|
15685d7a21 | ||
|
|
4f144d9e82 | ||
|
|
b6ed0bbaca | ||
|
|
711c605212 | ||
|
|
c630159c22 | ||
|
|
ff6a765fac | ||
|
|
531a508c0d | ||
|
|
bfb33988be | ||
|
|
b923e88b23 | ||
|
|
c9ff78abfd | ||
|
|
0f5de8524f | ||
|
|
0ddc31d3f4 | ||
|
|
a74510ba00 | ||
|
|
c6ffd69e9c | ||
|
|
783c23b663 | ||
|
|
d842693889 | ||
|
|
92ca973b3d | ||
|
|
771bcb54cf | ||
|
|
6671608a3f | ||
|
|
fe686b3c1f | ||
|
|
c53be403e2 | ||
|
|
26f7ef3c67 | ||
|
|
2a383a66c5 | ||
|
|
1c49092205 | ||
|
|
680971316d | ||
|
|
ad28a0ec68 | ||
|
|
fa70a64af9 | ||
|
|
f32917df31 | ||
|
|
d735649fcd | ||
|
|
d26ccd1f4d |
28
.appveyor.yml
Normal file
28
.appveyor.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
# appveyor file
|
||||
# http://www.appveyor.com/docs/appveyor-yml
|
||||
|
||||
max_jobs: 1
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf true
|
||||
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
|
||||
environment:
|
||||
nodejs_version: "4"
|
||||
matrix:
|
||||
- PLATFORM: windows-10-store
|
||||
JUST_BUILD: --justBuild
|
||||
install:
|
||||
- npm cache clean -f
|
||||
- node --version
|
||||
- npm install -g cordova-paramedic@https://github.com/apache/cordova-paramedic.git
|
||||
- npm install -g cordova
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- cordova-paramedic --config pr\%PLATFORM% --plugin . %JUST_BUILD%
|
||||
10
.eslintrc.yml
Normal file
10
.eslintrc.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
root: true
|
||||
extends: semistandard
|
||||
rules:
|
||||
indent:
|
||||
- error
|
||||
- 4
|
||||
camelcase: off
|
||||
padded-blocks: off
|
||||
operator-linebreak: off
|
||||
no-throw-literal: off
|
||||
16
.jshintrc
16
.jshintrc
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"browser": true
|
||||
, "devel": true
|
||||
, "bitwise": true
|
||||
, "undef": true
|
||||
, "trailing": true
|
||||
, "quotmark": false
|
||||
, "indent": 4
|
||||
, "unused": "vars"
|
||||
, "latedef": "nofunc"
|
||||
, "globals": {
|
||||
"module": false,
|
||||
"exports": false,
|
||||
"require": false
|
||||
}
|
||||
}
|
||||
92
.travis.yml
92
.travis.yml
@@ -1,4 +1,90 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- "4.2"
|
||||
addons:
|
||||
jwt:
|
||||
secure: TZ88IEvAw1bsWPWxvDzXdpi2NK0i3PN4hG15+vDpIt6wXGVPknjxuXWJeLj7TqBpAIvP7XDfS8ZvHVPLe7fe8oOchZPLuiDw9VVIk6cnHjE6wpoavdGc/1mDJ3Bi4PDcHwRUr5ng5spYQqqlTwcECkH/q7iPgudiFM6rlOlGRyA=
|
||||
env:
|
||||
global:
|
||||
- SAUCE_USERNAME=snay
|
||||
- TRAVIS_NODE_VERSION="4.2"
|
||||
matrix:
|
||||
include:
|
||||
- env: PLATFORM=browser-chrome
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-firefox
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-safari
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-edge
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=ios-9.3
|
||||
os: osx
|
||||
osx_image: xcode7.3
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=ios-10.0
|
||||
os: osx
|
||||
osx_image: xcode7.3
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=android-4.4
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- platform-tools
|
||||
- tools
|
||||
- env: PLATFORM=android-5.1
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- platform-tools
|
||||
- tools
|
||||
- env: PLATFORM=android-6.0
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- platform-tools
|
||||
- tools
|
||||
- env: PLATFORM=android-7.0
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- platform-tools
|
||||
- tools
|
||||
before_install:
|
||||
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm
|
||||
&& git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm
|
||||
install $TRAVIS_NODE_VERSION
|
||||
- node --version
|
||||
- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi
|
||||
- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi
|
||||
- if [[ "$PLATFORM" =~ android ]]; then echo y | android update sdk -u --filter android-22,android-23,android-24,android-25,android-26;
|
||||
fi
|
||||
- git clone https://github.com/apache/cordova-paramedic /tmp/paramedic && pushd /tmp/paramedic
|
||||
&& npm install && popd
|
||||
- npm install -g cordova
|
||||
install:
|
||||
- npm install
|
||||
script:
|
||||
- npm test
|
||||
- node /tmp/paramedic/main.js --config pr/$PLATFORM --plugin $(pwd) --shouldUseSauce
|
||||
--buildName travis-plugin-inappbrowser-$TRAVIS_JOB_NUMBER
|
||||
|
||||
43
README.md
43
README.md
@@ -21,9 +21,9 @@ description: Open an in-app browser window.
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
|Android 4.4|Android 5.1|iOS|Windows 10 Store|Travis CI|
|
||||
|:-:|:-:|:-:|:-:|:-:|
|
||||
|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-inappbrowser/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-inappbrowser/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-inappbrowser/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-inappbrowser/)|[](https://travis-ci.org/apache/cordova-plugin-inappbrowser)|
|
||||
|AppVeyor|Travis CI|
|
||||
|:-:|:-:|
|
||||
|[](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-inappbrowser)|[](https://travis-ci.org/apache/cordova-plugin-inappbrowser)|
|
||||
|
||||
# cordova-plugin-inappbrowser
|
||||
|
||||
@@ -57,7 +57,7 @@ plugin). The hook of `window.open` will be removed in a future major release.
|
||||
Until the hook is removed from the plugin, apps can manually restore the default
|
||||
behaviour:
|
||||
|
||||
delete window.open // Reverts the call back to it's prototype's default
|
||||
delete window.open // Reverts the call back to its prototype's default
|
||||
|
||||
Although `window.open` is in the global scope, InAppBrowser is not available until after the `deviceready` event.
|
||||
|
||||
@@ -66,7 +66,7 @@ Although `window.open` is in the global scope, InAppBrowser is not available unt
|
||||
console.log("window.open works well");
|
||||
}
|
||||
|
||||
Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20InAppBrowser%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
|
||||
Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22cordova-plugin-inappbrowser%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
|
||||
|
||||
|
||||
## <a id="reference">Reference</a>
|
||||
@@ -101,28 +101,30 @@ instance, or the system browser.
|
||||
|
||||
- __options__: Options for the `InAppBrowser`. Optional, defaulting to: `location=yes`. _(String)_
|
||||
|
||||
The `options` string must not contain any blank space, and each feature's name/value pairs must be separated by a comma. Feature names are case insensitive. All platforms support the value below:
|
||||
The `options` string must not contain any blank space, and each feature's name/value pairs must be separated by a comma. Feature names are case insensitive.
|
||||
|
||||
All platforms support:
|
||||
|
||||
- __location__: Set to `yes` or `no` to turn the `InAppBrowser`'s location bar on or off.
|
||||
|
||||
Android only:
|
||||
Android 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.
|
||||
- __clearcache__: set to `yes` to have the browser's cookie cache cleared before the new window is opened
|
||||
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened
|
||||
- __zoom__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `yes`.
|
||||
- __hardwareback__: set to `yes` to use the hardware back button to navigate backwards through the `InAppBrowser`'s history. If there is no previous page, the `InAppBrowser` will close. The default value is `yes`, so you must set it to `no` if you want the back button to simply close the InAppBrowser.
|
||||
- __zoom__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `yes`.
|
||||
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
|
||||
- __shouldPauseOnSuspend__: Set to `yes` to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues like described in [CB-11013](https://issues.apache.org/jira/browse/CB-11013)).
|
||||
- __useWideViewPort__: Sets whether the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is `no`, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is `yes` and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. (defaults to `yes`).
|
||||
|
||||
iOS only:
|
||||
iOS supports these additional options:
|
||||
|
||||
- __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself.
|
||||
- __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property.
|
||||
- __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.
|
||||
- __clearcache__: set to `yes` to have the browser's cookie cache cleared before the new window is opened
|
||||
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened
|
||||
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened
|
||||
- __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself.
|
||||
- __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property.
|
||||
- __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`)
|
||||
- __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`).
|
||||
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
|
||||
@@ -133,23 +135,24 @@ instance, or the system browser.
|
||||
- __transitionstyle__: Set to `fliphorizontal`, `crossdissolve` or `coververtical` to set the [transition style](http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/modalTransitionStyle) (defaults to `coververtical`).
|
||||
- __toolbarposition__: Set to `top` or `bottom` (default is `bottom`). Causes the toolbar to be at the top or bottom of the window.
|
||||
|
||||
Windows only:
|
||||
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.
|
||||
- __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.
|
||||
- __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
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- BlackBerry 10
|
||||
- Browser
|
||||
- Firefox OS
|
||||
- iOS
|
||||
- OSX
|
||||
- Windows 8 and 8.1
|
||||
- Windows Phone 7 and 8
|
||||
- Browser
|
||||
|
||||
### Example
|
||||
|
||||
@@ -323,10 +326,10 @@ function executeScriptCallBack(params) {
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows 8 and 8.1
|
||||
- Windows Phone 7 and 8
|
||||
- Browser
|
||||
|
||||
### Browser Quirks
|
||||
|
||||
@@ -359,10 +362,10 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows 8 and 8.1
|
||||
- Windows Phone 7 and 8
|
||||
- Browser
|
||||
|
||||
### Quick Example
|
||||
|
||||
@@ -383,11 +386,11 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- Browser
|
||||
- Firefox OS
|
||||
- iOS
|
||||
- Windows 8 and 8.1
|
||||
- Windows Phone 7 and 8
|
||||
- Browser
|
||||
|
||||
### Quick Example
|
||||
|
||||
@@ -406,9 +409,9 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows 8 and 8.1
|
||||
- Browser
|
||||
|
||||
### Quick Example
|
||||
|
||||
@@ -460,9 +463,9 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows 8 and 8.1
|
||||
- Browser
|
||||
|
||||
### Quick Example
|
||||
|
||||
|
||||
@@ -20,6 +20,31 @@
|
||||
-->
|
||||
# Release Notes
|
||||
|
||||
### 1.7.2 (Nov 06, 2017)
|
||||
* [CB-13473](https://issues.apache.org/jira/browse/CB-13473) (CI) Removed **Browser** builds from AppVeyor
|
||||
* [CB-13472](https://issues.apache.org/jira/browse/CB-13472) (CI) Fixed Travis **Android** builds again
|
||||
* [CB-13347](https://issues.apache.org/jira/browse/CB-13347) Enable thirdparty cookies on `>=Android 5.0` device
|
||||
* [CB-12895](https://issues.apache.org/jira/browse/CB-12895) added `eslint` and removed `jshint`
|
||||
* [CB-12975](https://issues.apache.org/jira/browse/CB-12975) (docs) Resort and reword `cordova.InAppBrowser.open` `options` lists
|
||||
* [CB-12586](https://issues.apache.org/jira/browse/CB-12586) (iOS) fix method `hide` doesn't work
|
||||
* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`.
|
||||
|
||||
### 1.7.1 (Apr 27, 2017)
|
||||
* [CB-12622](https://issues.apache.org/jira/browse/CB-12622) Added **Android 6.0** build badges to `README`
|
||||
* [CB-12266](https://issues.apache.org/jira/browse/CB-12266) (browser platform) loadstop event.url is now a string instead of an object, aligning it with the other platforms.
|
||||
* [CB-12685](https://issues.apache.org/jira/browse/CB-12685) added `package.json` to tests folder
|
||||
* [CB-11248](https://issues.apache.org/jira/browse/CB-11248) `InAppBrowser` no focus on input text fields
|
||||
|
||||
### 1.7.0 (Feb 28, 2017)
|
||||
* [CB-12366](https://issues.apache.org/jira/browse/CB-12366) **iOS:** Reduce `tmpWindow` level to prevent overlapping statusbar
|
||||
* [CB-12364](https://issues.apache.org/jira/browse/CB-12364) **Windows:** `Inappbrowser` inject file manual tests are not working
|
||||
* [CB-12353](https://issues.apache.org/jira/browse/CB-12353) Corrected merges usage in `plugin.xml`
|
||||
* [CB-12369](https://issues.apache.org/jira/browse/CB-12369) Add plugin typings from `DefinitelyTyped`
|
||||
* [CB-12363](https://issues.apache.org/jira/browse/CB-12363) Added build badges for **iOS 9.3** and **iOS 10.0**
|
||||
* [CB-9148](https://issues.apache.org/jira/browse/CB-9148) **Android:** Add Support for `input[type=file]` File Chooser
|
||||
* [CB-11136](https://issues.apache.org/jira/browse/CB-11136) (ios) Fix `InAppBrowser` when closing with `WKWebView`
|
||||
* [CB-10799](https://issues.apache.org/jira/browse/CB-10799) **iOS:** fix toolbar is shown in incorrect position when in-call status bar
|
||||
|
||||
### 1.6.1 (Dec 14, 2016)
|
||||
* [CB-12237](https://issues.apache.org/jira/browse/CB-12237) - Update version in package.json to correct 1.6.1-dev
|
||||
* [CB-12236](https://issues.apache.org/jira/browse/CB-12236) - Fixed RELEASENOTES for cordova-plugin-inappbrowser
|
||||
|
||||
18
package.json
18
package.json
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"name": "cordova-plugin-inappbrowser",
|
||||
"version": "1.6.1",
|
||||
"version": "1.7.2",
|
||||
"description": "Cordova InAppBrowser Plugin",
|
||||
"types": "./types/index.d.ts",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-inappbrowser",
|
||||
"platforms": [
|
||||
@@ -21,6 +22,9 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/apache/cordova-plugin-inappbrowser"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://issues.apache.org/jira/browse/CB"
|
||||
},
|
||||
"keywords": [
|
||||
"cordova",
|
||||
"in",
|
||||
@@ -40,8 +44,8 @@
|
||||
"cordova-firefoxos"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "npm run jshint",
|
||||
"jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests"
|
||||
"test": "npm run eslint",
|
||||
"eslint": "node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests"
|
||||
},
|
||||
"engines": {
|
||||
"cordovaDependencies": {
|
||||
@@ -56,6 +60,12 @@
|
||||
"author": "Apache Software Foundation",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"jshint": "^2.6.0"
|
||||
"eslint": "^4.0.0",
|
||||
"eslint-config-semistandard": "^11.0.0",
|
||||
"eslint-config-standard": "^10.2.1",
|
||||
"eslint-plugin-import": "^2.3.0",
|
||||
"eslint-plugin-node": "^5.0.0",
|
||||
"eslint-plugin-promise": "^3.5.0",
|
||||
"eslint-plugin-standard": "^3.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
30
plugin.xml
30
plugin.xml
@@ -20,7 +20,7 @@
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-inappbrowser"
|
||||
version="1.6.1">
|
||||
version="1.7.2">
|
||||
|
||||
<name>InAppBrowser</name>
|
||||
<description>Cordova InAppBrowser Plugin</description>
|
||||
@@ -40,7 +40,7 @@
|
||||
<clobbers target="window.open" />
|
||||
</js-module>
|
||||
<config-file target="res/xml/config.xml" parent="/*">
|
||||
<feature name="InAppBrowser">
|
||||
<feature name="InAppBrowser">
|
||||
<param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
@@ -74,7 +74,7 @@
|
||||
<clobbers target="window.open" />
|
||||
</js-module>
|
||||
<config-file target="res/xml/config.xml" parent="/*">
|
||||
<feature name="InAppBrowser">
|
||||
<feature name="InAppBrowser">
|
||||
<param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
@@ -82,24 +82,24 @@
|
||||
<source-file src="src/amazon/InAppBrowser.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
||||
<source-file src="src/android/InAppBrowserDialog.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
||||
<source-file src="src/amazon/InAppChromeClient.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
||||
|
||||
|
||||
<!-- drawable src/android/resources -->
|
||||
<resource-file src="src/android/res/drawable-hdpi/ic_action_next_item.png" target="res/drawable-hdpi/ic_action_next_item.png" />
|
||||
<resource-file src="src/android/res/drawable-mdpi/ic_action_next_item.png" target="res/drawable-mdpi/ic_action_next_item.png" />
|
||||
<resource-file src="src/android/res/drawable-xhdpi/ic_action_next_item.png" target="res/drawable-xhdpi/ic_action_next_item.png" />
|
||||
<resource-file src="src/android/res/drawable-xxhdpi/ic_action_next_item.png" target="res/drawable-xxhdpi/ic_action_next_item.png" />
|
||||
|
||||
|
||||
<resource-file src="src/android/res/drawable-hdpi/ic_action_previous_item.png" target="res/drawable-hdpi/ic_action_previous_item.png" />
|
||||
<resource-file src="src/android/res/drawable-mdpi/ic_action_previous_item.png" target="res/drawable-mdpi/ic_action_previous_item.png" />
|
||||
<resource-file src="src/android/res/drawable-xhdpi/ic_action_previous_item.png" target="res/drawable-xhdpi/ic_action_previous_item.png" />
|
||||
<resource-file src="src/android/res/drawable-xxhdpi/ic_action_previous_item.png" target="res/drawable-xxhdpi/ic_action_previous_item.png" />
|
||||
|
||||
|
||||
<resource-file src="src/android/res/drawable-hdpi/ic_action_remove.png" target="res/drawable-hdpi/ic_action_remove.png" />
|
||||
<resource-file src="src/android/res/drawable-mdpi/ic_action_remove.png" target="res/drawable-mdpi/ic_action_remove.png" />
|
||||
<resource-file src="src/android/res/drawable-xhdpi/ic_action_remove.png" target="res/drawable-xhdpi/ic_action_remove.png" />
|
||||
<resource-file src="src/android/res/drawable-xxhdpi/ic_action_remove.png" target="res/drawable-xxhdpi/ic_action_remove.png" />
|
||||
</platform>
|
||||
|
||||
|
||||
<!-- ubuntu -->
|
||||
<platform name="ubuntu">
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
@@ -118,16 +118,16 @@
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
<clobbers target="cordova.InAppBrowser.open" />
|
||||
<clobbers target="window.open" />
|
||||
</js-module>
|
||||
</js-module>
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="InAppBrowser">
|
||||
<param name="ios-package" value="CDVInAppBrowser" />
|
||||
<param name="ios-package" value="CDVInAppBrowser" />
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<header-file src="src/ios/CDVInAppBrowser.h" />
|
||||
<source-file src="src/ios/CDVInAppBrowser.m" />
|
||||
|
||||
|
||||
<framework src="CoreGraphics.framework" />
|
||||
</platform>
|
||||
|
||||
@@ -175,7 +175,7 @@
|
||||
<config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
|
||||
<Capability Name="ID_CAP_NETWORKING"/>
|
||||
</config-file>
|
||||
|
||||
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
<clobbers target="cordova.InAppBrowser.open" />
|
||||
<clobbers target="window.open" />
|
||||
@@ -211,11 +211,11 @@
|
||||
<clobbers target="window.open" />
|
||||
</js-module>
|
||||
<js-module src="src/windows/InAppBrowserProxy.js" name="InAppBrowserProxy">
|
||||
<merges target="" />
|
||||
<runs />
|
||||
</js-module>
|
||||
<asset src="www/inappbrowser.css" target="css/inappbrowser.css" />
|
||||
</platform>
|
||||
|
||||
|
||||
<!-- firefoxos -->
|
||||
<platform name="firefoxos">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
@@ -226,7 +226,7 @@
|
||||
<clobbers target="window.open" />
|
||||
</js-module>
|
||||
<js-module src="src/firefoxos/InAppBrowserProxy.js" name="InAppBrowserProxy">
|
||||
<merges target="" />
|
||||
<runs />
|
||||
</js-module>
|
||||
</platform>
|
||||
|
||||
@@ -237,7 +237,7 @@
|
||||
<clobbers target="window.open" />
|
||||
</js-module>
|
||||
<js-module src="src/browser/InAppBrowserProxy.js" name="InAppBrowserProxy">
|
||||
<merges target="" />
|
||||
<runs />
|
||||
</js-module>
|
||||
</platform>
|
||||
</plugin>
|
||||
|
||||
@@ -41,6 +41,8 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.CookieSyncManager;
|
||||
import android.webkit.HttpAuthHandler;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
@@ -103,6 +105,10 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
private boolean mediaPlaybackRequiresUserGesture = false;
|
||||
private boolean shouldPauseInAppBrowser = false;
|
||||
private boolean useWideViewPort = true;
|
||||
private ValueCallback<Uri> mUploadCallback;
|
||||
private ValueCallback<Uri[]> mUploadCallbackLollipop;
|
||||
private final static int FILECHOOSER_REQUESTCODE = 1;
|
||||
private final static int FILECHOOSER_REQUESTCODE_LOLLIPOP = 2;
|
||||
|
||||
/**
|
||||
* Executes the request and returns PluginResult.
|
||||
@@ -722,7 +728,49 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
inAppWebView = new WebView(cordova.getActivity());
|
||||
inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
||||
inAppWebView.setId(Integer.valueOf(6));
|
||||
inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView));
|
||||
// File Chooser Implemented ChromeClient
|
||||
inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView) {
|
||||
// For Android 5.0+
|
||||
public boolean onShowFileChooser (WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
|
||||
{
|
||||
LOG.d(LOG_TAG, "File Chooser 5.0+");
|
||||
// If callback exists, finish it.
|
||||
if(mUploadCallbackLollipop != null) {
|
||||
mUploadCallbackLollipop.onReceiveValue(null);
|
||||
}
|
||||
mUploadCallbackLollipop = filePathCallback;
|
||||
|
||||
// Create File Chooser Intent
|
||||
Intent content = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
content.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
content.setType("*/*");
|
||||
|
||||
// Run cordova startActivityForResult
|
||||
cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE_LOLLIPOP);
|
||||
return true;
|
||||
}
|
||||
|
||||
// For Android 4.1+
|
||||
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
|
||||
{
|
||||
LOG.d(LOG_TAG, "File Chooser 4.1+");
|
||||
// Call file chooser for Android 3.0+
|
||||
openFileChooser(uploadMsg, acceptType);
|
||||
}
|
||||
|
||||
// For Android 3.0+
|
||||
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType)
|
||||
{
|
||||
LOG.d(LOG_TAG, "File Chooser 3.0+");
|
||||
mUploadCallback = uploadMsg;
|
||||
Intent content = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
content.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
|
||||
// run startActivityForResult
|
||||
cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE);
|
||||
}
|
||||
|
||||
});
|
||||
WebViewClient client = new InAppBrowserClient(thatWebView, edittext);
|
||||
inAppWebView.setWebViewClient(client);
|
||||
WebSettings settings = inAppWebView.getSettings();
|
||||
@@ -761,6 +809,11 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
CookieManager.getInstance().removeSessionCookie();
|
||||
}
|
||||
|
||||
// Enable Thirdparty Cookies on >=Android 5.0 device
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
CookieManager.getInstance().setAcceptThirdPartyCookies(inAppWebView,true);
|
||||
}
|
||||
|
||||
inAppWebView.loadUrl(url);
|
||||
inAppWebView.setId(Integer.valueOf(6));
|
||||
inAppWebView.getSettings().setLoadWithOverviewMode(true);
|
||||
@@ -831,6 +884,42 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive File Data from File Chooser
|
||||
*
|
||||
* @param requestCode the requested code from chromeclient
|
||||
* @param resultCode the result code returned from android system
|
||||
* @param intent the data from android file chooser
|
||||
*/
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
// For Android >= 5.0
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
LOG.d(LOG_TAG, "onActivityResult (For Android >= 5.0)");
|
||||
// If RequestCode or Callback is Invalid
|
||||
if(requestCode != FILECHOOSER_REQUESTCODE_LOLLIPOP || mUploadCallbackLollipop == null) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
return;
|
||||
}
|
||||
mUploadCallbackLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
|
||||
mUploadCallbackLollipop = null;
|
||||
}
|
||||
// For Android < 5.0
|
||||
else {
|
||||
LOG.d(LOG_TAG, "onActivityResult (For Android < 5.0)");
|
||||
// If RequestCode or Callback is Invalid
|
||||
if(requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
return;
|
||||
}
|
||||
|
||||
if (null == mUploadCallback) return;
|
||||
Uri result = intent == null || resultCode != cordova.getActivity().RESULT_OK ? null : intent.getData();
|
||||
|
||||
mUploadCallback.onReceiveValue(result);
|
||||
mUploadCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The webview client receives notifications about appView
|
||||
*/
|
||||
@@ -962,6 +1051,10 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
CookieSyncManager.getInstance().sync();
|
||||
}
|
||||
|
||||
// https://issues.apache.org/jira/browse/CB-11248
|
||||
view.clearFocus();
|
||||
view.requestFocus();
|
||||
|
||||
try {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("type", LOAD_STOP_EVENT);
|
||||
|
||||
@@ -29,27 +29,43 @@ var browserWrap,
|
||||
forwardButton,
|
||||
closeButton;
|
||||
|
||||
function attachNavigationEvents(element, callback) {
|
||||
function attachNavigationEvents (element, callback) {
|
||||
var onError = function () {
|
||||
callback({ type: "loaderror", url: this.contentWindow.location}, {keepCallback: true});
|
||||
try {
|
||||
callback({ type: 'loaderror', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: 'loaderror', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
|
||||
}
|
||||
};
|
||||
|
||||
element.addEventListener("pageshow", function () {
|
||||
callback({ type: "loadstart", url: this.contentWindow.location}, {keepCallback: true});
|
||||
element.addEventListener('pageshow', function () {
|
||||
try {
|
||||
callback({ type: 'loadstart', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: 'loadstart', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
|
||||
}
|
||||
});
|
||||
|
||||
element.addEventListener("load", function () {
|
||||
callback({ type: "loadstop", url: this.contentWindow.location}, {keepCallback: true});
|
||||
element.addEventListener('load', function () {
|
||||
try {
|
||||
callback({ type: 'loadstop', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: 'loadstop', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
|
||||
}
|
||||
});
|
||||
|
||||
element.addEventListener("error", onError);
|
||||
element.addEventListener("abort", onError);
|
||||
element.addEventListener('error', onError);
|
||||
element.addEventListener('abort', onError);
|
||||
}
|
||||
|
||||
var IAB = {
|
||||
close: function (win, lose) {
|
||||
if (browserWrap) {
|
||||
if (win) win({ type: "exit" });
|
||||
// use the "open" function callback so that the exit event is fired properly
|
||||
if (IAB._win) IAB._win({ type: 'exit' });
|
||||
|
||||
browserWrap.parentNode.removeChild(browserWrap);
|
||||
browserWrap = null;
|
||||
@@ -59,109 +75,108 @@ var IAB = {
|
||||
|
||||
show: function (win, lose) {
|
||||
if (browserWrap) {
|
||||
browserWrap.style.display = "block";
|
||||
browserWrap.style.display = 'block';
|
||||
}
|
||||
},
|
||||
|
||||
open: function (win, lose, args) {
|
||||
var strUrl = args[0],
|
||||
target = args[1],
|
||||
features = args[2];
|
||||
var strUrl = args[0];
|
||||
var target = args[1];
|
||||
var features = args[2];
|
||||
|
||||
if (target === "_self" || !target) {
|
||||
IAB._win = win;
|
||||
|
||||
if (target === '_self' || !target) {
|
||||
window.location = strUrl;
|
||||
} else if (target === "_system") {
|
||||
modulemapper.getOriginalSymbol(window, 'window.open').call(window, strUrl, "_blank");
|
||||
} else if (target === '_system') {
|
||||
modulemapper.getOriginalSymbol(window, 'window.open').call(window, strUrl, '_blank');
|
||||
} else {
|
||||
// "_blank" or anything else
|
||||
if (!browserWrap) {
|
||||
browserWrap = document.createElement("div");
|
||||
browserWrap.style.position = "absolute";
|
||||
browserWrap.style.top = "0";
|
||||
browserWrap.style.left = "0";
|
||||
browserWrap.style.boxSizing = "border-box";
|
||||
browserWrap.style.borderWidth = "40px";
|
||||
browserWrap.style.width = "100vw";
|
||||
browserWrap.style.height = "100vh";
|
||||
browserWrap.style.borderStyle = "solid";
|
||||
browserWrap.style.borderColor = "rgba(0,0,0,0.25)";
|
||||
browserWrap = document.createElement('div');
|
||||
browserWrap.style.position = 'absolute';
|
||||
browserWrap.style.top = '0';
|
||||
browserWrap.style.left = '0';
|
||||
browserWrap.style.boxSizing = 'border-box';
|
||||
browserWrap.style.borderWidth = '40px';
|
||||
browserWrap.style.width = '100vw';
|
||||
browserWrap.style.height = '100vh';
|
||||
browserWrap.style.borderStyle = 'solid';
|
||||
browserWrap.style.borderColor = 'rgba(0,0,0,0.25)';
|
||||
|
||||
browserWrap.onclick = function () {
|
||||
setTimeout(function () {
|
||||
IAB.close(win);
|
||||
IAB.close();
|
||||
}, 0);
|
||||
};
|
||||
|
||||
document.body.appendChild(browserWrap);
|
||||
}
|
||||
|
||||
if (features.indexOf("hidden=yes") !== -1) {
|
||||
browserWrap.style.display = "none";
|
||||
if (features.indexOf('hidden=yes') !== -1) {
|
||||
browserWrap.style.display = 'none';
|
||||
}
|
||||
|
||||
popup = document.createElement("iframe");
|
||||
popup.style.borderWidth = "0px";
|
||||
popup.style.width = "100%";
|
||||
popup = document.createElement('iframe');
|
||||
popup.style.borderWidth = '0px';
|
||||
popup.style.width = '100%';
|
||||
|
||||
browserWrap.appendChild(popup);
|
||||
|
||||
if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) {
|
||||
popup.style.height = "calc(100% - 60px)";
|
||||
popup.style.marginBottom = "-4px";
|
||||
if (features.indexOf('location=yes') !== -1 || features.indexOf('location') === -1) {
|
||||
popup.style.height = 'calc(100% - 60px)';
|
||||
popup.style.marginBottom = '-4px';
|
||||
|
||||
navigationButtonsDiv = document.createElement("div");
|
||||
navigationButtonsDiv.style.height = "60px";
|
||||
navigationButtonsDiv.style.backgroundColor = "#404040";
|
||||
navigationButtonsDiv.style.zIndex = "999";
|
||||
navigationButtonsDiv = document.createElement('div');
|
||||
navigationButtonsDiv.style.height = '60px';
|
||||
navigationButtonsDiv.style.backgroundColor = '#404040';
|
||||
navigationButtonsDiv.style.zIndex = '999';
|
||||
navigationButtonsDiv.onclick = function (e) {
|
||||
e.cancelBubble = true;
|
||||
};
|
||||
|
||||
navigationButtonsDivInner = document.createElement("div");
|
||||
navigationButtonsDivInner.style.paddingTop = "10px";
|
||||
navigationButtonsDivInner.style.height = "50px";
|
||||
navigationButtonsDivInner.style.width = "160px";
|
||||
navigationButtonsDivInner.style.margin = "0 auto";
|
||||
navigationButtonsDivInner.style.backgroundColor = "#404040";
|
||||
navigationButtonsDivInner.style.zIndex = "999";
|
||||
navigationButtonsDivInner = document.createElement('div');
|
||||
navigationButtonsDivInner.style.paddingTop = '10px';
|
||||
navigationButtonsDivInner.style.height = '50px';
|
||||
navigationButtonsDivInner.style.width = '160px';
|
||||
navigationButtonsDivInner.style.margin = '0 auto';
|
||||
navigationButtonsDivInner.style.backgroundColor = '#404040';
|
||||
navigationButtonsDivInner.style.zIndex = '999';
|
||||
navigationButtonsDivInner.onclick = function (e) {
|
||||
e.cancelBubble = true;
|
||||
};
|
||||
|
||||
backButton = document.createElement('button');
|
||||
backButton.style.width = '40px';
|
||||
backButton.style.height = '40px';
|
||||
backButton.style.borderRadius = '40px';
|
||||
|
||||
backButton = document.createElement("button");
|
||||
backButton.style.width = "40px";
|
||||
backButton.style.height = "40px";
|
||||
backButton.style.borderRadius = "40px";
|
||||
|
||||
backButton.innerHTML = "←";
|
||||
backButton.addEventListener("click", function (e) {
|
||||
if (popup.canGoBack)
|
||||
popup.goBack();
|
||||
backButton.innerHTML = '←';
|
||||
backButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoBack) { popup.goBack(); }
|
||||
});
|
||||
|
||||
forwardButton = document.createElement("button");
|
||||
forwardButton.style.marginLeft = "20px";
|
||||
forwardButton.style.width = "40px";
|
||||
forwardButton.style.height = "40px";
|
||||
forwardButton.style.borderRadius = "40px";
|
||||
forwardButton = document.createElement('button');
|
||||
forwardButton.style.marginLeft = '20px';
|
||||
forwardButton.style.width = '40px';
|
||||
forwardButton.style.height = '40px';
|
||||
forwardButton.style.borderRadius = '40px';
|
||||
|
||||
forwardButton.innerHTML = "→";
|
||||
forwardButton.addEventListener("click", function (e) {
|
||||
if (popup.canGoForward)
|
||||
popup.goForward();
|
||||
forwardButton.innerHTML = '→';
|
||||
forwardButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoForward) { popup.goForward(); }
|
||||
});
|
||||
|
||||
closeButton = document.createElement("button");
|
||||
closeButton.style.marginLeft = "20px";
|
||||
closeButton.style.width = "40px";
|
||||
closeButton.style.height = "40px";
|
||||
closeButton.style.borderRadius = "40px";
|
||||
closeButton = document.createElement('button');
|
||||
closeButton.style.marginLeft = '20px';
|
||||
closeButton.style.width = '40px';
|
||||
closeButton.style.height = '40px';
|
||||
closeButton.style.borderRadius = '40px';
|
||||
|
||||
closeButton.innerHTML = "✖";
|
||||
closeButton.addEventListener("click", function (e) {
|
||||
closeButton.innerHTML = '✖';
|
||||
closeButton.addEventListener('click', function (e) {
|
||||
setTimeout(function () {
|
||||
IAB.close(win);
|
||||
IAB.close();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
@@ -176,7 +191,7 @@ var IAB = {
|
||||
|
||||
browserWrap.appendChild(navigationButtonsDiv);
|
||||
} else {
|
||||
popup.style.height = "100%";
|
||||
popup.style.height = '100%';
|
||||
}
|
||||
|
||||
// start listening for navigation events
|
||||
@@ -187,8 +202,8 @@ var IAB = {
|
||||
},
|
||||
|
||||
injectScriptCode: function (win, fail, args) {
|
||||
var code = args[0],
|
||||
hasCallback = args[1];
|
||||
var code = args[0];
|
||||
var hasCallback = args[1];
|
||||
|
||||
if (browserWrap && popup) {
|
||||
try {
|
||||
@@ -196,7 +211,7 @@ var IAB = {
|
||||
if (hasCallback) {
|
||||
win([]);
|
||||
}
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
console.error('Error occured while trying to injectScriptCode: ' + JSON.stringify(e));
|
||||
}
|
||||
}
|
||||
@@ -208,7 +223,7 @@ var IAB = {
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
injectStyleCode: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
|
||||
@@ -229,4 +244,4 @@ var IAB = {
|
||||
|
||||
module.exports = IAB;
|
||||
|
||||
require("cordova/exec/proxy").add("InAppBrowser", module.exports);
|
||||
require('cordova/exec/proxy').add('InAppBrowser', module.exports);
|
||||
|
||||
@@ -32,7 +32,7 @@ var IABExecs = {
|
||||
if (browserWrap) {
|
||||
browserWrap.parentNode.removeChild(browserWrap);
|
||||
browserWrap = null;
|
||||
if (typeof(win) == "function") win({type:'exit'});
|
||||
if (typeof (win) === 'function') win({type: 'exit'});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -48,17 +48,17 @@ var IABExecs = {
|
||||
},
|
||||
|
||||
open: function (win, lose, args) {
|
||||
var strUrl = args[0],
|
||||
target = args[1],
|
||||
features_string = args[2] || "location=yes", //location=yes is default
|
||||
features = {};
|
||||
var strUrl = args[0];
|
||||
var target = args[1];
|
||||
var features_string = args[2] || 'location=yes'; // location=yes is default
|
||||
var features = {};
|
||||
|
||||
var features_list = features_string.split(',');
|
||||
features_list.forEach(function(feature) {
|
||||
features_list.forEach(function (feature) {
|
||||
var tup = feature.split('=');
|
||||
if (tup[1] == 'yes') {
|
||||
if (tup[1] === 'yes') {
|
||||
tup[1] = true;
|
||||
} else if (tup[1] == 'no') {
|
||||
} else if (tup[1] === 'no') {
|
||||
tup[1] = false;
|
||||
} else {
|
||||
var number = parseInt(tup[1]);
|
||||
@@ -68,8 +68,7 @@ var IABExecs = {
|
||||
}
|
||||
features[tup[0]] = tup[1];
|
||||
});
|
||||
|
||||
function updateIframeSizeNoLocation() {
|
||||
function updateIframeSizeNoLocation () {
|
||||
browserWrap.style.width = window.innerWidth + 'px';
|
||||
browserWrap.style.height = window.innerHeight + 'px';
|
||||
browserWrap.style.zIndex = '999999999';
|
||||
@@ -117,7 +116,7 @@ var IABExecs = {
|
||||
|
||||
var checkForwardBackward = function () {
|
||||
var backReq = browserElem.getCanGoBack();
|
||||
backReq.onsuccess = function() {
|
||||
backReq.onsuccess = function () {
|
||||
if (this.result) {
|
||||
back.classList.remove('disabled');
|
||||
} else {
|
||||
@@ -125,7 +124,7 @@ var IABExecs = {
|
||||
}
|
||||
};
|
||||
var forwardReq = browserElem.getCanGoForward();
|
||||
forwardReq.onsuccess = function() {
|
||||
forwardReq.onsuccess = function () {
|
||||
if (this.result) {
|
||||
forward.classList.remove('disabled');
|
||||
} else {
|
||||
@@ -158,21 +157,21 @@ var IABExecs = {
|
||||
browserWrap.appendChild(browserElem);
|
||||
document.body.appendChild(browserWrap);
|
||||
|
||||
//we use mozbrowserlocationchange instead of mozbrowserloadstart to get the url
|
||||
browserElem.addEventListener('mozbrowserlocationchange', function(e){
|
||||
// we use mozbrowserlocationchange instead of mozbrowserloadstart to get the url
|
||||
browserElem.addEventListener('mozbrowserlocationchange', function (e) {
|
||||
win({
|
||||
type:'loadstart',
|
||||
url : e.detail
|
||||
type: 'loadstart',
|
||||
url: e.detail
|
||||
});
|
||||
}, false);
|
||||
browserElem.addEventListener('mozbrowserloadend', function(e){
|
||||
win({type:'loadstop'});
|
||||
browserElem.addEventListener('mozbrowserloadend', function (e) {
|
||||
win({type: 'loadstop'});
|
||||
}, false);
|
||||
browserElem.addEventListener('mozbrowsererror', function(e){
|
||||
win({type:'loaderror'});
|
||||
browserElem.addEventListener('mozbrowsererror', function (e) {
|
||||
win({type: 'loaderror'});
|
||||
}, false);
|
||||
browserElem.addEventListener('mozbrowserclose', function(e){
|
||||
win({type:'exit'});
|
||||
browserElem.addEventListener('mozbrowserclose', function (e) {
|
||||
win({type: 'exit'});
|
||||
}, false);
|
||||
} else {
|
||||
window.location = strUrl;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#define kInAppBrowserToolbarBarPositionTop @"top"
|
||||
|
||||
#define TOOLBAR_HEIGHT 44.0
|
||||
#define STATUSBAR_HEIGHT 20.0
|
||||
#define LOCATIONBAR_HEIGHT 21.0
|
||||
#define FOOTER_HEIGHT ((TOOLBAR_HEIGHT) + (LOCATIONBAR_HEIGHT))
|
||||
|
||||
@@ -238,7 +239,14 @@
|
||||
// Run later to avoid the "took a long time" log message.
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (weakSelf.inAppBrowserViewController != nil) {
|
||||
[weakSelf.viewController presentViewController:nav animated:YES completion:nil];
|
||||
CGRect frame = [[UIScreen mainScreen] bounds];
|
||||
UIWindow *tmpWindow = [[UIWindow alloc] initWithFrame:frame];
|
||||
UIViewController *tmpController = [[UIViewController alloc] init];
|
||||
[tmpWindow setRootViewController:tmpController];
|
||||
[tmpWindow setWindowLevel:UIWindowLevelNormal];
|
||||
|
||||
[tmpWindow makeKeyAndVisible];
|
||||
[tmpController presentViewController:nav animated:YES completion:nil];
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -262,7 +270,7 @@
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.inAppBrowserViewController != nil) {
|
||||
_previousStatusBarStyle = -1;
|
||||
[self.viewController dismissViewControllerAnimated:YES completion:nil];
|
||||
[self.inAppBrowserViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -425,7 +433,7 @@
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:scriptCallbackId];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
//if is an app store link, let the system handle it, otherwise it fails to load it
|
||||
else if ([[ url scheme] isEqualToString:@"itms-appss"] || [[ url scheme] isEqualToString:@"itms-apps"]) {
|
||||
[theWebView stopLoading];
|
||||
@@ -516,7 +524,7 @@
|
||||
#else
|
||||
_webViewDelegate = [[CDVWebViewDelegate alloc] initWithDelegate:self];
|
||||
#endif
|
||||
|
||||
|
||||
[self createViews];
|
||||
}
|
||||
|
||||
@@ -1041,11 +1049,11 @@
|
||||
|
||||
- (void) viewDidLoad {
|
||||
|
||||
CGRect frame = [UIApplication sharedApplication].statusBarFrame;
|
||||
|
||||
CGRect statusBarFrame = [self invertFrameIfNeeded:[UIApplication sharedApplication].statusBarFrame];
|
||||
statusBarFrame.size.height = STATUSBAR_HEIGHT;
|
||||
// simplified from: http://stackoverflow.com/a/25669695/219684
|
||||
|
||||
UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:[self invertFrameIfNeeded:frame]];
|
||||
UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:statusBarFrame];
|
||||
bgToolbar.barStyle = UIBarStyleDefault;
|
||||
[bgToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
|
||||
[self.view addSubview:bgToolbar];
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* jshint -W061 */
|
||||
/* global oxide */
|
||||
|
||||
oxide.addMessageHandler("EXECUTE", function(msg) {
|
||||
oxide.addMessageHandler('EXECUTE', function (msg) {
|
||||
var code = msg.args.code;
|
||||
try {
|
||||
msg.reply({result: eval(code)});
|
||||
} catch(e) {
|
||||
msg.error("Code threw exception: \"" + e + "\"");
|
||||
msg.reply({result: eval(code)}); // eslint-disable-line no-eval
|
||||
} catch (e) {
|
||||
msg.error('Code threw exception: "' + e + '"');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
@@ -21,9 +21,10 @@
|
||||
|
||||
/* jslint sloppy:true */
|
||||
/* global Windows:true, setImmediate */
|
||||
/* eslint standard/no-callback-literal : 0 */
|
||||
|
||||
var cordova = require('cordova'),
|
||||
urlutil = require('cordova/urlutil');
|
||||
var cordova = require('cordova');
|
||||
var urlutil = require('cordova/urlutil');
|
||||
|
||||
var browserWrap,
|
||||
popup,
|
||||
@@ -40,56 +41,56 @@ var browserWrap,
|
||||
// http://msdn.microsoft.com/en-us/library/windows/apps/dn301831.aspx
|
||||
var isWebViewAvailable = cordova.platformId === 'windows';
|
||||
|
||||
function attachNavigationEvents(element, callback) {
|
||||
function attachNavigationEvents (element, callback) {
|
||||
if (isWebViewAvailable) {
|
||||
element.addEventListener("MSWebViewNavigationStarting", function (e) {
|
||||
callback({ type: "loadstart", url: e.uri}, {keepCallback: true} );
|
||||
element.addEventListener('MSWebViewNavigationStarting', function (e) {
|
||||
callback({ type: 'loadstart', url: e.uri }, {keepCallback: true});
|
||||
});
|
||||
|
||||
element.addEventListener("MSWebViewNavigationCompleted", function (e) {
|
||||
element.addEventListener('MSWebViewNavigationCompleted', function (e) {
|
||||
if (e.isSuccess) {
|
||||
callback({ type: "loadstop", url: e.uri }, { keepCallback: true });
|
||||
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 });
|
||||
callback({ type: 'loaderror', url: e.uri, code: e.webErrorStatus, message: 'Navigation failed with error code ' + e.webErrorStatus }, { keepCallback: true });
|
||||
}
|
||||
});
|
||||
|
||||
element.addEventListener("MSWebViewUnviewableContentIdentified", function (e) {
|
||||
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 });
|
||||
callback({ type: 'loaderror', url: e.uri, code: e.webErrorStatus, message: 'Navigation failed with error code ' + e.webErrorStatus }, { keepCallback: true });
|
||||
});
|
||||
|
||||
element.addEventListener("MSWebViewContentLoading", function (e) {
|
||||
element.addEventListener('MSWebViewContentLoading', function (e) {
|
||||
if (navigationButtonsDiv && popup) {
|
||||
if (popup.canGoBack) {
|
||||
backButton.removeAttribute("disabled");
|
||||
backButton.removeAttribute('disabled');
|
||||
} else {
|
||||
backButton.setAttribute("disabled", "true");
|
||||
backButton.setAttribute('disabled', 'true');
|
||||
}
|
||||
|
||||
if (popup.canGoForward) {
|
||||
forwardButton.removeAttribute("disabled");
|
||||
forwardButton.removeAttribute('disabled');
|
||||
} else {
|
||||
forwardButton.setAttribute("disabled", "true");
|
||||
forwardButton.setAttribute('disabled', 'true');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var onError = function () {
|
||||
callback({ type: "loaderror", url: this.contentWindow.location}, {keepCallback: true});
|
||||
callback({ type: 'loaderror', url: this.contentWindow.location }, {keepCallback: true});
|
||||
};
|
||||
|
||||
element.addEventListener("unload", function () {
|
||||
callback({ type: "loadstart", 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('load', function () {
|
||||
callback({ type: 'loadstop', url: this.contentWindow.location }, {keepCallback: true});
|
||||
});
|
||||
|
||||
element.addEventListener("error", onError);
|
||||
element.addEventListener("abort", onError);
|
||||
element.addEventListener('error', onError);
|
||||
element.addEventListener('abort', onError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +99,7 @@ var IAB = {
|
||||
setImmediate(function () {
|
||||
if (browserWrap) {
|
||||
if (navigationEventsCallback) {
|
||||
navigationEventsCallback({ type: "exit" });
|
||||
navigationEventsCallback({ type: 'exit' });
|
||||
}
|
||||
|
||||
browserWrap.parentNode.removeChild(browserWrap);
|
||||
@@ -107,52 +108,52 @@ var IAB = {
|
||||
browserWrap = null;
|
||||
popup = null;
|
||||
|
||||
document.removeEventListener("backbutton", hardwareBackCallback, false);
|
||||
document.removeEventListener('backbutton', hardwareBackCallback, false);
|
||||
}
|
||||
});
|
||||
},
|
||||
show: function (win, lose) {
|
||||
setImmediate(function () {
|
||||
if (browserWrap) {
|
||||
browserWrap.style.display = "block";
|
||||
browserWrap.style.display = 'block';
|
||||
}
|
||||
});
|
||||
},
|
||||
hide: function (win, lose) {
|
||||
if (browserWrap) {
|
||||
browserWrap.style.display = "none";
|
||||
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],
|
||||
target = args[1],
|
||||
features = args[2],
|
||||
url;
|
||||
var strUrl = args[0];
|
||||
var target = args[1];
|
||||
var features = args[2];
|
||||
var url;
|
||||
|
||||
navigationEventsCallback = win;
|
||||
|
||||
if (target === "_system") {
|
||||
if (target === '_system') {
|
||||
url = new Windows.Foundation.Uri(strUrl);
|
||||
Windows.System.Launcher.launchUriAsync(url);
|
||||
} else if (target === "_self" || !target) {
|
||||
} 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");
|
||||
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";
|
||||
browserWrap = document.createElement('div');
|
||||
browserWrap.className = 'inAppBrowserWrap';
|
||||
|
||||
if (features.indexOf("fullscreen=yes") > -1) {
|
||||
browserWrap.classList.add("inAppBrowserWrapFullscreen");
|
||||
if (features.indexOf('fullscreen=yes') > -1) {
|
||||
browserWrap.classList.add('inAppBrowserWrapFullscreen');
|
||||
}
|
||||
|
||||
// Save body overflow style to be able to reset it back later
|
||||
@@ -166,22 +167,22 @@ var IAB = {
|
||||
|
||||
document.body.appendChild(browserWrap);
|
||||
// Hide scrollbars for the whole body while inappbrowser's window is open
|
||||
document.body.style.msOverflowStyle = "none";
|
||||
document.body.style.msOverflowStyle = 'none';
|
||||
}
|
||||
|
||||
if (features.indexOf("hidden=yes") !== -1) {
|
||||
browserWrap.style.display = "none";
|
||||
if (features.indexOf('hidden=yes') !== -1) {
|
||||
browserWrap.style.display = 'none';
|
||||
}
|
||||
|
||||
popup = document.createElement(isWebViewAvailable ? "x-ms-webview" : "iframe");
|
||||
if (popup instanceof HTMLIFrameElement) {
|
||||
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.backgroundColor = 'white';
|
||||
}
|
||||
popup.style.borderWidth = "0px";
|
||||
popup.style.width = "100%";
|
||||
popup.style.marginBottom = "-5px";
|
||||
popup.style.borderWidth = '0px';
|
||||
popup.style.width = '100%';
|
||||
popup.style.marginBottom = '-5px';
|
||||
|
||||
browserWrap.appendChild(popup);
|
||||
|
||||
@@ -191,14 +192,14 @@ var IAB = {
|
||||
}, 0);
|
||||
};
|
||||
|
||||
if (features.indexOf("hardwareback=yes") > -1 || features.indexOf("hardwareback") === -1) {
|
||||
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';
|
||||
throw 'Exit the app'; // eslint-disable-line no-throw-literal
|
||||
}
|
||||
|
||||
if (popup.canGoBack) {
|
||||
@@ -207,59 +208,57 @@ var IAB = {
|
||||
closeHandler();
|
||||
}
|
||||
};
|
||||
} else if (features.indexOf("hardwareback=no") > -1) {
|
||||
} else if (features.indexOf('hardwareback=no') > -1) {
|
||||
hardwareBackCallback = function () {
|
||||
if (browserWrap.style.display === 'none') {
|
||||
// See comment above
|
||||
throw 'Exit the app';
|
||||
throw 'Exit the app'; // eslint-disable-line no-throw-literal
|
||||
}
|
||||
|
||||
closeHandler();
|
||||
};
|
||||
}
|
||||
|
||||
document.addEventListener("backbutton", hardwareBackCallback, false);
|
||||
document.addEventListener('backbutton', hardwareBackCallback, false);
|
||||
|
||||
if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) {
|
||||
popup.style.height = "calc(100% - 70px)";
|
||||
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 = 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 = 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();
|
||||
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();
|
||||
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);
|
||||
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");
|
||||
backButton.setAttribute('disabled', 'true');
|
||||
forwardButton.setAttribute('disabled', 'true');
|
||||
}
|
||||
|
||||
navigationButtonsDivInner.appendChild(backButton);
|
||||
@@ -269,14 +268,14 @@ var IAB = {
|
||||
|
||||
browserWrap.appendChild(navigationButtonsDiv);
|
||||
} else {
|
||||
popup.style.height = "100%";
|
||||
popup.style.height = '100%';
|
||||
}
|
||||
|
||||
// start listening for navigation events
|
||||
attachNavigationEvents(popup, navigationEventsCallback);
|
||||
|
||||
if (isWebViewAvailable) {
|
||||
strUrl = strUrl.replace("ms-appx://", "ms-appx-web://");
|
||||
strUrl = strUrl.replace('ms-appx://', 'ms-appx-web://');
|
||||
}
|
||||
popup.src = strUrl;
|
||||
}
|
||||
@@ -285,11 +284,11 @@ var IAB = {
|
||||
|
||||
injectScriptCode: function (win, fail, args) {
|
||||
setImmediate(function () {
|
||||
var code = args[0],
|
||||
hasCallback = args[1];
|
||||
var code = args[0];
|
||||
var hasCallback = args[1];
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
var op = popup.invokeScriptAsync("eval", code);
|
||||
var op = popup.invokeScriptAsync('eval', code);
|
||||
op.oncomplete = function (e) {
|
||||
if (hasCallback) {
|
||||
// return null if event target is unavailable by some reason
|
||||
@@ -305,19 +304,20 @@ var IAB = {
|
||||
|
||||
injectScriptFile: function (win, fail, args) {
|
||||
setImmediate(function () {
|
||||
var filePath = args[0],
|
||||
hasCallback = args[1];
|
||||
var filePath = args[0];
|
||||
var hasCallback = args[1];
|
||||
|
||||
if (!!filePath) {
|
||||
if (filePath) {
|
||||
filePath = urlutil.makeAbsolute(filePath);
|
||||
}
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
var uri = new Windows.Foundation.Uri(filePath);
|
||||
// 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) {
|
||||
var op = popup.invokeScriptAsync('eval', code);
|
||||
op.oncomplete = function (e) {
|
||||
if (hasCallback) {
|
||||
var result = [e.target.result];
|
||||
win(result);
|
||||
@@ -333,8 +333,8 @@ var IAB = {
|
||||
|
||||
injectStyleCode: function (win, fail, args) {
|
||||
setImmediate(function () {
|
||||
var code = args[0],
|
||||
hasCallback = args[1];
|
||||
var code = args[0];
|
||||
var hasCallback = args[1];
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
injectCSS(popup, code, hasCallback && win);
|
||||
@@ -344,13 +344,14 @@ var IAB = {
|
||||
|
||||
injectStyleFile: function (win, fail, args) {
|
||||
setImmediate(function () {
|
||||
var filePath = args[0],
|
||||
hasCallback = args[1];
|
||||
var filePath = args[0];
|
||||
var hasCallback = args[1];
|
||||
|
||||
filePath = filePath && urlutil.makeAbsolute(filePath);
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
var uri = new Windows.Foundation.Uri(filePath);
|
||||
// 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) {
|
||||
@@ -366,11 +367,11 @@ var IAB = {
|
||||
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)"
|
||||
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() {
|
||||
var op = webView.invokeScriptAsync('eval', evalWrapper);
|
||||
op.oncomplete = function () {
|
||||
if (callback) {
|
||||
callback([]);
|
||||
}
|
||||
@@ -381,4 +382,4 @@ function injectCSS (webView, cssCode, callback) {
|
||||
|
||||
module.exports = IAB;
|
||||
|
||||
require("cordova/exec/proxy").add("InAppBrowser", module.exports);
|
||||
require('cordova/exec/proxy').add('InAppBrowser', module.exports);
|
||||
|
||||
2
tests/.eslintrc.yml
Normal file
2
tests/.eslintrc.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
env:
|
||||
jasmine: true
|
||||
14
tests/package.json
Normal file
14
tests/package.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "cordova-plugin-inappbrowser-tests",
|
||||
"version": "1.7.1-dev",
|
||||
"description": "",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-inappbrowser-tests",
|
||||
"platforms": []
|
||||
},
|
||||
"keywords": [
|
||||
"ecosystem:cordova"
|
||||
],
|
||||
"author": "",
|
||||
"license": "Apache 2.0"
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-inappbrowser-tests"
|
||||
version="1.6.1">
|
||||
version="1.7.2">
|
||||
<name>Cordova InAppBrowser Plugin Tests</name>
|
||||
<license>Apache 2.0</license>
|
||||
|
||||
|
||||
@@ -16,5 +16,5 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
var d = document.getElementById("header");
|
||||
d.innerHTML = "Script file successfully injected";
|
||||
var d = document.getElementById('header');
|
||||
d.innerHTML = 'Script file successfully injected';
|
||||
|
||||
169
tests/tests.js
169
tests/tests.js
@@ -19,23 +19,27 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* jshint jasmine: true */
|
||||
/* global MSApp */
|
||||
|
||||
var cordova = require('cordova');
|
||||
var isWindows = cordova.platformId == 'windows';
|
||||
var isWindows = cordova.platformId === 'windows';
|
||||
var 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 () {
|
||||
|
||||
describe('cordova.InAppBrowser', function () {
|
||||
|
||||
it("inappbrowser.spec.1 should exist", function () {
|
||||
it('inappbrowser.spec.1 should exist', function () {
|
||||
expect(cordova.InAppBrowser).toBeDefined();
|
||||
});
|
||||
|
||||
it("inappbrowser.spec.2 should contain open function", function () {
|
||||
it('inappbrowser.spec.2 should contain open function', function () {
|
||||
expect(cordova.InAppBrowser.open).toBeDefined();
|
||||
expect(cordova.InAppBrowser.open).toEqual(jasmine.any(Function));
|
||||
});
|
||||
@@ -43,7 +47,7 @@ exports.defineAutoTests = function () {
|
||||
|
||||
describe('open method', function () {
|
||||
|
||||
if (cordova.platformId == 'osx') {
|
||||
if (cordova.platformId === 'osx') {
|
||||
pending('Open method not fully supported on OSX.');
|
||||
return;
|
||||
}
|
||||
@@ -73,15 +77,16 @@ exports.defineAutoTests = function () {
|
||||
setTimeout(done, 2000);
|
||||
});
|
||||
|
||||
function verifyEvent(evt, type) {
|
||||
function verifyEvent (evt, type) {
|
||||
expect(evt).toBeDefined();
|
||||
expect(evt.type).toEqual(type);
|
||||
if (type !== 'exit') { // `exit` event does not have url field
|
||||
// `exit` event does not have url field, browser returns null url for CORS requests
|
||||
if (type !== 'exit' && !isBrowser) {
|
||||
expect(evt.url).toEqual(url);
|
||||
}
|
||||
}
|
||||
|
||||
function verifyLoadErrorEvent(evt) {
|
||||
function verifyLoadErrorEvent (evt) {
|
||||
expect(evt).toBeDefined();
|
||||
expect(evt.type).toEqual('loaderror');
|
||||
expect(evt.url).toEqual(badUrl);
|
||||
@@ -89,7 +94,7 @@ exports.defineAutoTests = function () {
|
||||
expect(evt.message).toEqual(jasmine.any(String));
|
||||
}
|
||||
|
||||
it("inappbrowser.spec.3 should retun InAppBrowser instance with required methods", function () {
|
||||
it('inappbrowser.spec.3 should return InAppBrowser instance with required methods', function () {
|
||||
iabInstance = cordova.InAppBrowser.open(url, '_blank');
|
||||
|
||||
expect(iabInstance).toBeDefined();
|
||||
@@ -103,7 +108,7 @@ exports.defineAutoTests = function () {
|
||||
expect(iabInstance.insertCSS).toEqual(jasmine.any(Function));
|
||||
});
|
||||
|
||||
it("inappbrowser.spec.4 should support loadstart and loadstop events", function (done) {
|
||||
it('inappbrowser.spec.4 should support loadstart and loadstop events', function (done) {
|
||||
var onLoadStart = jasmine.createSpy('loadstart event callback').and.callFake(function (evt) {
|
||||
verifyEvent(evt, 'loadstart');
|
||||
});
|
||||
@@ -112,12 +117,16 @@ exports.defineAutoTests = function () {
|
||||
iabInstance.addEventListener('loadstart', onLoadStart);
|
||||
iabInstance.addEventListener('loadstop', function (evt) {
|
||||
verifyEvent(evt, 'loadstop');
|
||||
expect(onLoadStart).toHaveBeenCalled();
|
||||
if (!isBrowser) {
|
||||
// according to documentation, "loadstart" event is not supported on browser
|
||||
// https://github.com/apache/cordova-plugin-inappbrowser#browser-quirks-1
|
||||
expect(onLoadStart).toHaveBeenCalled();
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("inappbrowser.spec.5 should support exit event", function (done) {
|
||||
it('inappbrowser.spec.5 should support exit event', function (done) {
|
||||
iabInstance = cordova.InAppBrowser.open(url, '_blank');
|
||||
iabInstance.addEventListener('exit', function (evt) {
|
||||
verifyEvent(evt, 'exit');
|
||||
@@ -127,7 +136,12 @@ exports.defineAutoTests = function () {
|
||||
iabInstance = null;
|
||||
});
|
||||
|
||||
it("inappbrowser.spec.6 should support loaderror event", function (done) {
|
||||
it('inappbrowser.spec.6 should support loaderror event', function (done) {
|
||||
if (isBrowser) {
|
||||
// according to documentation, "loaderror" event is not supported on browser
|
||||
// https://github.com/apache/cordova-plugin-inappbrowser#browser-quirks-1
|
||||
pending('Browser platform doesn\'t support loaderror event');
|
||||
}
|
||||
iabInstance = cordova.InAppBrowser.open(badUrl, '_blank');
|
||||
iabInstance.addEventListener('loaderror', function (evt) {
|
||||
verifyLoadErrorEvent(evt);
|
||||
@@ -139,15 +153,15 @@ exports.defineAutoTests = function () {
|
||||
|
||||
exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
|
||||
function doOpen(url, target, params, numExpectedRedirects, useWindowOpen) {
|
||||
function doOpen (url, target, params, numExpectedRedirects, useWindowOpen) {
|
||||
numExpectedRedirects = numExpectedRedirects || 0;
|
||||
useWindowOpen = useWindowOpen || false;
|
||||
console.log("Opening " + url);
|
||||
console.log('Opening ' + url);
|
||||
|
||||
var counts;
|
||||
var lastLoadStartURL;
|
||||
var wasReset = false;
|
||||
function reset() {
|
||||
function reset () {
|
||||
counts = {
|
||||
'loaderror': 0,
|
||||
'loadstart': 0,
|
||||
@@ -168,49 +182,48 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
if (useWindowOpen) {
|
||||
console.log('Use window.open() for url');
|
||||
iab = window.open(url, target, params, callbacks);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
iab = cordova.InAppBrowser.open(url, target, params, callbacks);
|
||||
}
|
||||
if (!iab) {
|
||||
alert('open returned ' + iab);
|
||||
alert('open returned ' + iab); // eslint-disable-line no-undef
|
||||
return;
|
||||
}
|
||||
|
||||
function logEvent(e) {
|
||||
function logEvent (e) {
|
||||
console.log('IAB event=' + JSON.stringify(e));
|
||||
counts[e.type]++;
|
||||
// Verify that event.url gets updated on redirects.
|
||||
if (e.type == 'loadstart') {
|
||||
if (e.url == lastLoadStartURL) {
|
||||
alert('Unexpected: loadstart fired multiple times for the same URL.');
|
||||
if (e.type === 'loadstart') {
|
||||
if (e.url === lastLoadStartURL) {
|
||||
alert('Unexpected: loadstart fired multiple times for the same URL.'); // eslint-disable-line no-undef
|
||||
}
|
||||
lastLoadStartURL = e.url;
|
||||
}
|
||||
// Verify the right number of loadstart events were fired.
|
||||
if (e.type == 'loadstop' || e.type == 'loaderror') {
|
||||
if (e.url != lastLoadStartURL) {
|
||||
alert('Unexpected: ' + e.type + ' event.url != loadstart\'s event.url');
|
||||
if (e.type === 'loadstop' || e.type === 'loaderror') {
|
||||
if (e.url !== lastLoadStartURL) {
|
||||
alert('Unexpected: ' + e.type + ' event.url != loadstart\'s event.url'); // eslint-disable-line no-undef
|
||||
}
|
||||
if (numExpectedRedirects === 0 && counts.loadstart !== 1) {
|
||||
// Do allow a loaderror without a loadstart (e.g. in the case of an invalid URL).
|
||||
if (!(e.type == 'loaderror' && counts.loadstart === 0)) {
|
||||
alert('Unexpected: got multiple loadstart events. (' + counts.loadstart + ')');
|
||||
if (!(e.type === 'loaderror' && counts.loadstart === 0)) {
|
||||
alert('Unexpected: got multiple loadstart events. (' + counts.loadstart + ')'); // eslint-disable-line no-undef
|
||||
}
|
||||
} else if (numExpectedRedirects > 0 && counts.loadstart < (numExpectedRedirects + 1)) {
|
||||
alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts.loadstart);
|
||||
alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts.loadstart); // eslint-disable-line no-undef
|
||||
}
|
||||
wasReset = true;
|
||||
numExpectedRedirects = 0;
|
||||
reset();
|
||||
}
|
||||
// Verify that loadend / loaderror was called.
|
||||
if (e.type == 'exit') {
|
||||
if (e.type === 'exit') {
|
||||
var numStopEvents = counts.loadstop + counts.loaderror;
|
||||
if (numStopEvents === 0 && !wasReset) {
|
||||
alert('Unexpected: browser closed without a loadstop or loaderror.');
|
||||
alert('Unexpected: browser closed without a loadstop or loaderror.'); // eslint-disable-line no-undef
|
||||
} else if (numStopEvents > 1) {
|
||||
alert('Unexpected: got multiple loadstop/loaderror events.');
|
||||
alert('Unexpected: got multiple loadstop/loaderror events.'); // eslint-disable-line no-undef
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,33 +231,31 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
return iab;
|
||||
}
|
||||
|
||||
function doHookOpen(url, target, params, numExpectedRedirects) {
|
||||
function doHookOpen (url, target, params, numExpectedRedirects) {
|
||||
var originalFunc = window.open;
|
||||
var wasClobbered = window.hasOwnProperty('open');
|
||||
window.open = cordova.InAppBrowser.open;
|
||||
|
||||
try {
|
||||
doOpen(url, target, params, numExpectedRedirects, true);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
if (wasClobbered) {
|
||||
window.open = originalFunc;
|
||||
}
|
||||
else {
|
||||
console.log('just delete, to restore open from prototype');
|
||||
} else {
|
||||
console.log('just delete, to restore open from prototype');
|
||||
delete window.open;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function openWithStyle(url, cssUrl, useCallback) {
|
||||
function openWithStyle (url, cssUrl, useCallback) {
|
||||
var iab = doOpen(url, '_blank', 'location=yes');
|
||||
var callback = function (results) {
|
||||
if (results && results.length === 0) {
|
||||
alert('Results verified');
|
||||
alert('Results verified'); // eslint-disable-line no-undef
|
||||
} else {
|
||||
console.log(results);
|
||||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results));
|
||||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef
|
||||
}
|
||||
};
|
||||
if (cssUrl) {
|
||||
@@ -254,21 +265,21 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
} else {
|
||||
iab.addEventListener('loadstop', function (event) {
|
||||
iab.insertCSS({ code: '#style-update-literal { \ndisplay: block !important; \n}' },
|
||||
useCallback && callback);
|
||||
useCallback && callback);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function openWithScript(url, jsUrl, useCallback) {
|
||||
function openWithScript (url, jsUrl, useCallback) {
|
||||
var iab = doOpen(url, '_blank', 'location=yes');
|
||||
if (jsUrl) {
|
||||
iab.addEventListener('loadstop', function (event) {
|
||||
iab.executeScript({ file: jsUrl }, useCallback && function (results) {
|
||||
if (results && results.length === 0) {
|
||||
alert('Results verified');
|
||||
alert('Results verified'); // eslint-disable-line no-undef
|
||||
} else {
|
||||
console.log(results);
|
||||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results));
|
||||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -281,33 +292,33 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'})()';
|
||||
iab.executeScript({ code: code }, useCallback && function (results) {
|
||||
if (results && results.length === 1 && results[0] === 'abc') {
|
||||
alert('Results verified');
|
||||
alert('Results verified'); // eslint-disable-line no-undef
|
||||
} else {
|
||||
console.log(results);
|
||||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results));
|
||||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
var hiddenwnd = null;
|
||||
var loadlistener = function (event) { alert('background window loaded '); };
|
||||
function openHidden(url, startHidden) {
|
||||
var loadlistener = function (event) { alert('background window loaded '); }; // eslint-disable-line no-undef
|
||||
function openHidden (url, startHidden) {
|
||||
var shopt = (startHidden) ? 'hidden=yes' : '';
|
||||
hiddenwnd = cordova.InAppBrowser.open(url, 'random_string', shopt);
|
||||
if (!hiddenwnd) {
|
||||
alert('cordova.InAppBrowser.open returned ' + hiddenwnd);
|
||||
alert('cordova.InAppBrowser.open returned ' + hiddenwnd); // eslint-disable-line no-undef
|
||||
return;
|
||||
}
|
||||
if (startHidden) hiddenwnd.addEventListener('loadstop', loadlistener);
|
||||
}
|
||||
function showHidden() {
|
||||
if (!!hiddenwnd) {
|
||||
function showHidden () {
|
||||
if (hiddenwnd) {
|
||||
hiddenwnd.show();
|
||||
}
|
||||
}
|
||||
function closeHidden() {
|
||||
if (!!hiddenwnd) {
|
||||
function closeHidden () {
|
||||
if (hiddenwnd) {
|
||||
hiddenwnd.removeEventListener('loadstop', loadlistener);
|
||||
hiddenwnd.close();
|
||||
hiddenwnd = null;
|
||||
@@ -452,14 +463,14 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<p/> <div id="openHardwareBackYes"></div>' +
|
||||
'Expected result: hardwareback=yes pressing back button should navigate backwards in history then close InAppBrowser' +
|
||||
'<p/> <div id="openHardwareBackNo"></div>' +
|
||||
'Expected result: hardwareback=no pressing back button should close InAppBrowser regardless history' +
|
||||
'Expected result: hardwareback=no pressing back button should close InAppBrowser regardless history' +
|
||||
'<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() {
|
||||
MSApp.execUnsafeLocalFunction(function () {
|
||||
contentEl.innerHTML = info_div + 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;
|
||||
});
|
||||
@@ -468,18 +479,18 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
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;
|
||||
document.getElementById('user-agent').textContent = navigator.userAgent;
|
||||
|
||||
// we are already in cdvtests directory
|
||||
var basePath = 'iab-resources/';
|
||||
var localhtml = basePath + 'local.html',
|
||||
localpdf = basePath + 'local.pdf',
|
||||
injecthtml = basePath + 'inject.html',
|
||||
injectjs = isWindows ? basePath + 'inject.js' : 'inject.js',
|
||||
injectcss = isWindows ? basePath + 'inject.css' : 'inject.css',
|
||||
videohtml = basePath + 'video.html';
|
||||
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';
|
||||
|
||||
//Local
|
||||
// Local
|
||||
createActionButton('target=Default', function () {
|
||||
doOpen(localhtml);
|
||||
}, 'openLocal');
|
||||
@@ -508,7 +519,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
doOpen(localhtml, 'random_string', 'toolbarposition=top,location=no');
|
||||
}, 'openLocalRandomToolBarTopNoLocation');
|
||||
|
||||
//White Listed
|
||||
// White Listed
|
||||
createActionButton('* target=Default', function () {
|
||||
doOpen('http://cordova.apache.org');
|
||||
}, 'openWhiteListed');
|
||||
@@ -531,7 +542,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
doOpen('http://cordova.apache.org', 'random_string', 'location=no');
|
||||
}, 'openWhiteListedRandomNoLocation');
|
||||
|
||||
//Non White Listed
|
||||
// Non White Listed
|
||||
createActionButton('target=Default', function () {
|
||||
doOpen('http://www.apple.com');
|
||||
}, 'openNonWhiteListed');
|
||||
@@ -554,7 +565,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
doOpen('http://www.apple.com', 'random_string', 'location=no');
|
||||
}, 'openNonWhiteListedRandomNoLocation');
|
||||
|
||||
//Page with redirect
|
||||
// Page with redirect
|
||||
createActionButton('http://google.co.uk', function () {
|
||||
doOpen('http://google.co.uk', 'random_string', '', 1);
|
||||
}, 'openRedirect301');
|
||||
@@ -562,7 +573,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
doOpen('http://goo.gl/pUFqg', 'random_string', '', 2);
|
||||
}, 'openRedirect302');
|
||||
|
||||
//PDF URL
|
||||
// PDF URL
|
||||
createActionButton('Remote URL', function () {
|
||||
doOpen('http://www.stluciadance.com/prospectus_file/sample.pdf');
|
||||
}, 'openPDF');
|
||||
@@ -570,7 +581,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
doOpen(localpdf, '_blank');
|
||||
}, 'openPDFBlank');
|
||||
|
||||
//Invalid URL
|
||||
// Invalid URL
|
||||
createActionButton('Invalid Scheme', function () {
|
||||
doOpen('x-ttp://www.invalid.com/', '_blank');
|
||||
}, 'openInvalidScheme');
|
||||
@@ -581,7 +592,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
doOpen('nonexistent.html', '_blank');
|
||||
}, 'openInvalidMissing');
|
||||
|
||||
//CSS / JS injection
|
||||
// CSS / JS injection
|
||||
createActionButton('Original Document', function () {
|
||||
doOpen(injecthtml, '_blank');
|
||||
}, 'openOriginalDocument');
|
||||
@@ -610,7 +621,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
openWithScript(injecthtml, null, true);
|
||||
}, 'openScriptLiteralInjectionCallback');
|
||||
|
||||
//Open hidden
|
||||
// Open hidden
|
||||
createActionButton('Create Hidden', function () {
|
||||
openHidden('https://www.google.co.uk', true);
|
||||
}, 'openHidden');
|
||||
@@ -630,7 +641,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
}, 2000);
|
||||
}, 'openVisibleAndHide');
|
||||
|
||||
//Clearing cache
|
||||
// Clearing cache
|
||||
createActionButton('Clear Browser Cache', function () {
|
||||
doOpen('https://www.google.co.uk', '_blank', 'clearcache=yes');
|
||||
}, 'openClearCache');
|
||||
@@ -638,7 +649,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
doOpen('https://www.google.co.uk', '_blank', 'clearsessioncache=yes');
|
||||
}, 'openClearSessionCache');
|
||||
|
||||
//Video tag
|
||||
// Video tag
|
||||
createActionButton('Remote Video', function () {
|
||||
doOpen(videohtml, '_blank');
|
||||
}, 'openRemoteVideo');
|
||||
@@ -649,7 +660,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
doOpen(videohtml, '_blank', 'mediaPlaybackRequiresUserAction=yes');
|
||||
}, 'openRemoteNeedUserYesVideo');
|
||||
|
||||
//Local With Anchor Tag
|
||||
// Local With Anchor Tag
|
||||
createActionButton('Anchor1', function () {
|
||||
doOpen(localhtml + '#bogusanchor', '_blank');
|
||||
}, 'openAnchor1');
|
||||
@@ -667,17 +678,17 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
createActionButton('hardwareback=no', function () {
|
||||
doOpen('http://cordova.apache.org', '_blank', 'hardwareback=no');
|
||||
}, 'openHardwareBackNo');
|
||||
createActionButton('no hardwareback -> hardwareback=no -> no hardwareback', function() {
|
||||
createActionButton('no hardwareback -> hardwareback=no -> no hardwareback', function () {
|
||||
var ref = cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes');
|
||||
ref.addEventListener('loadstop', function() {
|
||||
ref.addEventListener('loadstop', function () {
|
||||
ref.close();
|
||||
});
|
||||
ref.addEventListener('exit', function() {
|
||||
ref.addEventListener('exit', function () {
|
||||
var ref2 = cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes,hardwareback=no');
|
||||
ref2.addEventListener('loadstop', function() {
|
||||
ref2.addEventListener('loadstop', function () {
|
||||
ref2.close();
|
||||
});
|
||||
ref2.addEventListener('exit', function() {
|
||||
ref2.addEventListener('exit', function () {
|
||||
cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes');
|
||||
});
|
||||
});
|
||||
|
||||
221
types/index.d.ts
vendored
Normal file
221
types/index.d.ts
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
// Type definitions for Apache Cordova InAppBrowser plugin
|
||||
// Project: https://github.com/apache/cordova-plugin-inappbrowser
|
||||
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
//
|
||||
// Copyright (c) Microsoft Open Technologies Inc
|
||||
// Licensed under the MIT license.
|
||||
|
||||
interface Window {
|
||||
/**
|
||||
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
|
||||
* @param url The URL to load.
|
||||
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
|
||||
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
|
||||
* The options string must not contain any blank space, and each feature's
|
||||
* name/value pairs must be separated by a comma. Feature names are case insensitive.
|
||||
*/
|
||||
open(url: string, target?: "_self", options?: string): InAppBrowser;
|
||||
/**
|
||||
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
|
||||
* @param url The URL to load.
|
||||
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
|
||||
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
|
||||
* The options string must not contain any blank space, and each feature's
|
||||
* name/value pairs must be separated by a comma. Feature names are case insensitive.
|
||||
*/
|
||||
open(url: string, target?: "_blank", options?: string): InAppBrowser;
|
||||
/**
|
||||
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
|
||||
* @param url The URL to load.
|
||||
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
|
||||
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
|
||||
* The options string must not contain any blank space, and each feature's
|
||||
* name/value pairs must be separated by a comma. Feature names are case insensitive.
|
||||
*/
|
||||
open(url: string, target?: "_system", options?: string): InAppBrowser;
|
||||
/**
|
||||
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
|
||||
* @param url The URL to load.
|
||||
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
|
||||
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
|
||||
* The options string must not contain any blank space, and each feature's
|
||||
* name/value pairs must be separated by a comma. Feature names are case insensitive.
|
||||
*/
|
||||
open(url: string, target?: string, options?: string, replace?: boolean): InAppBrowser;
|
||||
}
|
||||
|
||||
/**
|
||||
* The object returned from a call to window.open.
|
||||
* NOTE: The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs.
|
||||
*/
|
||||
interface InAppBrowser extends Window {
|
||||
onloadstart: (type: InAppBrowserEvent) => void;
|
||||
onloadstop: (type: InAppBrowserEvent) => void;
|
||||
onloaderror: (type: InAppBrowserEvent) => void;
|
||||
onexit: (type: InAppBrowserEvent) => void;
|
||||
// addEventListener overloads
|
||||
/**
|
||||
* Adds a listener for an event from the InAppBrowser.
|
||||
* @param type the event to listen for
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
addEventListener(type: "loadstart", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Adds a listener for an event from the InAppBrowser.
|
||||
* @param type the event to listen for
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
addEventListener(type: "loadstop", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Adds a listener for an event from the InAppBrowser.
|
||||
* @param type the event to listen for
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
addEventListener(type: "loaderror", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Adds a listener for an event from the InAppBrowser.
|
||||
* @param type the event to listen for
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
addEventListener(type: "exit", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Adds a listener for an event from the InAppBrowser.
|
||||
* @param type the event to listen for
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an Event object as a parameter.
|
||||
*/
|
||||
addEventListener(type: string, callback: (event: Event) => void): void;
|
||||
// removeEventListener overloads
|
||||
/**
|
||||
* Removes a listener for an event from the InAppBrowser.
|
||||
* @param type The event to stop listening for.
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
removeEventListener(type: "loadstart", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Removes a listener for an event from the InAppBrowser.
|
||||
* @param type The event to stop listening for.
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
removeEventListener(type: "loadstop", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Removes a listener for an event from the InAppBrowser.
|
||||
* @param type The event to stop listening for.
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
removeEventListener(type: "loaderror", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Removes a listener for an event from the InAppBrowser.
|
||||
* @param type The event to stop listening for.
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
removeEventListener(type: "exit", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Removes a listener for an event from the InAppBrowser.
|
||||
* @param type The event to stop listening for.
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an Event object as a parameter.
|
||||
*/
|
||||
removeEventListener(type: string, callback: (event: Event) => void): void;
|
||||
/** Closes the InAppBrowser window. */
|
||||
close(): void;
|
||||
/** Hides the InAppBrowser window. Calling this has no effect if the InAppBrowser was already hidden. */
|
||||
hide(): void;
|
||||
/**
|
||||
* Displays an InAppBrowser window that was opened hidden. Calling this has no effect
|
||||
* if the InAppBrowser was already visible.
|
||||
*/
|
||||
show(): void;
|
||||
/**
|
||||
* Injects JavaScript code into the InAppBrowser window.
|
||||
* @param script Details of the script to run, specifying either a file or code key.
|
||||
* @param callback The function that executes after the JavaScript code is injected.
|
||||
* If the injected script is of type code, the callback executes with
|
||||
* a single parameter, which is the return value of the script, wrapped in an Array.
|
||||
* For multi-line scripts, this is the return value of the last statement,
|
||||
* or the last expression evaluated.
|
||||
*/
|
||||
executeScript(script: { code: string }, callback: (result: any) => void): void;
|
||||
/**
|
||||
* Injects JavaScript code into the InAppBrowser window.
|
||||
* @param script Details of the script to run, specifying either a file or code key.
|
||||
* @param callback The function that executes after the JavaScript code is injected.
|
||||
* If the injected script is of type code, the callback executes with
|
||||
* a single parameter, which is the return value of the script, wrapped in an Array.
|
||||
* For multi-line scripts, this is the return value of the last statement,
|
||||
* or the last expression evaluated.
|
||||
*/
|
||||
executeScript(script: { file: string }, callback: (result: any) => void): void;
|
||||
/**
|
||||
* Injects CSS into the InAppBrowser window.
|
||||
* @param css Details of the script to run, specifying either a file or code key.
|
||||
* @param callback The function that executes after the CSS is injected.
|
||||
*/
|
||||
insertCSS(css: { code: string }, callback: () => void): void;
|
||||
/**
|
||||
* Injects CSS into the InAppBrowser window.
|
||||
* @param css Details of the script to run, specifying either a file or code key.
|
||||
* @param callback The function that executes after the CSS is injected.
|
||||
*/
|
||||
insertCSS(css: { file: string }, callback: () => void): void;
|
||||
}
|
||||
|
||||
interface InAppBrowserEvent extends Event {
|
||||
/** the eventname, either loadstart, loadstop, loaderror, or exit. */
|
||||
type: string;
|
||||
/** the URL that was loaded. */
|
||||
url: string;
|
||||
/** the error code, only in the case of loaderror. */
|
||||
code: number;
|
||||
/** the error message, only in the case of loaderror. */
|
||||
message: string;
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
(function() {
|
||||
(function () {
|
||||
// special patch to correctly work on Ripple emulator (CB-9760)
|
||||
if (window.parent && !!window.parent.ripple) { // https://gist.github.com/triceam/4658021
|
||||
module.exports = window.open.bind(window); // fallback to default window.open behaviour
|
||||
@@ -31,13 +31,13 @@
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
var urlutil = require('cordova/urlutil');
|
||||
|
||||
function InAppBrowser() {
|
||||
this.channels = {
|
||||
function InAppBrowser () {
|
||||
this.channels = {
|
||||
'loadstart': channel.create('loadstart'),
|
||||
'loadstop' : channel.create('loadstop'),
|
||||
'loaderror' : channel.create('loaderror'),
|
||||
'exit' : channel.create('exit')
|
||||
};
|
||||
'loadstop': channel.create('loadstop'),
|
||||
'loaderror': channel.create('loaderror'),
|
||||
'exit': channel.create('exit')
|
||||
};
|
||||
}
|
||||
|
||||
InAppBrowser.prototype = {
|
||||
@@ -47,47 +47,47 @@
|
||||
}
|
||||
},
|
||||
close: function (eventname) {
|
||||
exec(null, null, "InAppBrowser", "close", []);
|
||||
exec(null, null, 'InAppBrowser', 'close', []);
|
||||
},
|
||||
show: function (eventname) {
|
||||
exec(null, null, "InAppBrowser", "show", []);
|
||||
exec(null, null, 'InAppBrowser', 'show', []);
|
||||
},
|
||||
hide: function (eventname) {
|
||||
exec(null, null, "InAppBrowser", "hide", []);
|
||||
exec(null, null, 'InAppBrowser', 'hide', []);
|
||||
},
|
||||
addEventListener: function (eventname,f) {
|
||||
addEventListener: function (eventname, f) {
|
||||
if (eventname in this.channels) {
|
||||
this.channels[eventname].subscribe(f);
|
||||
}
|
||||
},
|
||||
removeEventListener: function(eventname, f) {
|
||||
removeEventListener: function (eventname, f) {
|
||||
if (eventname in this.channels) {
|
||||
this.channels[eventname].unsubscribe(f);
|
||||
}
|
||||
},
|
||||
|
||||
executeScript: function(injectDetails, cb) {
|
||||
executeScript: function (injectDetails, cb) {
|
||||
if (injectDetails.code) {
|
||||
exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]);
|
||||
exec(cb, null, 'InAppBrowser', 'injectScriptCode', [injectDetails.code, !!cb]);
|
||||
} else if (injectDetails.file) {
|
||||
exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]);
|
||||
exec(cb, null, 'InAppBrowser', 'injectScriptFile', [injectDetails.file, !!cb]);
|
||||
} else {
|
||||
throw new Error('executeScript requires exactly one of code or file to be specified');
|
||||
}
|
||||
},
|
||||
|
||||
insertCSS: function(injectDetails, cb) {
|
||||
insertCSS: function (injectDetails, cb) {
|
||||
if (injectDetails.code) {
|
||||
exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]);
|
||||
exec(cb, null, 'InAppBrowser', 'injectStyleCode', [injectDetails.code, !!cb]);
|
||||
} else if (injectDetails.file) {
|
||||
exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]);
|
||||
exec(cb, null, 'InAppBrowser', 'injectStyleFile', [injectDetails.file, !!cb]);
|
||||
} else {
|
||||
throw new Error('insertCSS requires exactly one of code or file to be specified');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function(strUrl, strWindowName, strWindowFeatures, callbacks) {
|
||||
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');
|
||||
@@ -102,13 +102,13 @@
|
||||
iab.addEventListener(callbackName, callbacks[callbackName]);
|
||||
}
|
||||
|
||||
var cb = function(eventname) {
|
||||
iab._eventHandler(eventname);
|
||||
var cb = function (eventname) {
|
||||
iab._eventHandler(eventname);
|
||||
};
|
||||
|
||||
strWindowFeatures = strWindowFeatures || "";
|
||||
strWindowFeatures = strWindowFeatures || '';
|
||||
|
||||
exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
|
||||
exec(cb, cb, 'InAppBrowser', 'open', [strUrl, strWindowName, strWindowFeatures]);
|
||||
return iab;
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*jslint sloppy:true */
|
||||
/*global Windows:true, require, document, setTimeout, window, module */
|
||||
/* jslint sloppy:true */
|
||||
/* global Windows:true, require, document, setTimeout, window, module */
|
||||
|
||||
var browserWrap;
|
||||
|
||||
@@ -36,33 +36,33 @@ var IAB = {
|
||||
/* empty block, ran out of bacon?
|
||||
if (browserWrap) {
|
||||
|
||||
}*/
|
||||
} */
|
||||
},
|
||||
hide: function (win, lose) {
|
||||
/* empty block, ran out of bacon?
|
||||
if (browserWrap) {
|
||||
|
||||
}*/
|
||||
} */
|
||||
},
|
||||
open: function (win, lose, args) {
|
||||
var strUrl = args[0],
|
||||
target = args[1],
|
||||
url,
|
||||
elem;
|
||||
var strUrl = args[0];
|
||||
var target = args[1];
|
||||
var url;
|
||||
var elem;
|
||||
|
||||
if (target === "_system") {
|
||||
if (target === '_system') {
|
||||
url = new Windows.Foundation.Uri(strUrl);
|
||||
Windows.System.Launcher.launchUriAsync(url);
|
||||
} else if (target === "_blank") {
|
||||
} else if (target === '_blank') {
|
||||
if (!browserWrap) {
|
||||
browserWrap = document.createElement("div");
|
||||
browserWrap.style.position = "absolute";
|
||||
browserWrap.style.width = (window.innerWidth - 80) + "px";
|
||||
browserWrap.style.height = (window.innerHeight - 80) + "px";
|
||||
browserWrap.style.borderWidth = "40px";
|
||||
browserWrap.style.borderStyle = "solid";
|
||||
browserWrap.style.borderColor = "rgba(0,0,0,0.25)";
|
||||
browserWrap.style.zIndex = "9999999";
|
||||
browserWrap = document.createElement('div');
|
||||
browserWrap.style.position = 'absolute';
|
||||
browserWrap.style.width = (window.innerWidth - 80) + 'px';
|
||||
browserWrap.style.height = (window.innerHeight - 80) + 'px';
|
||||
browserWrap.style.borderWidth = '40px';
|
||||
browserWrap.style.borderStyle = 'solid';
|
||||
browserWrap.style.borderColor = 'rgba(0,0,0,0.25)';
|
||||
browserWrap.style.zIndex = '9999999';
|
||||
|
||||
browserWrap.onclick = function () {
|
||||
setTimeout(function () {
|
||||
@@ -74,33 +74,31 @@ var IAB = {
|
||||
}
|
||||
var localFile = (strUrl.indexOf('ms-appdata:///') > -1);
|
||||
if (localFile) {
|
||||
elem = document.createElement("x-ms-webview");
|
||||
elem.style.width = (window.innerWidth - 80) + "px";
|
||||
elem.style.height = (window.innerHeight - 80) + "px";
|
||||
elem.style.borderWidth = "0px";
|
||||
elem.name = "targetFrame";
|
||||
elem = document.createElement('x-ms-webview');
|
||||
elem.style.width = (window.innerWidth - 80) + 'px';
|
||||
elem.style.height = (window.innerHeight - 80) + 'px';
|
||||
elem.style.borderWidth = '0px';
|
||||
elem.name = 'targetFrame';
|
||||
elem.src = strUrl;
|
||||
|
||||
window.addEventListener("resize", function () {
|
||||
window.addEventListener('resize', function () {
|
||||
if (browserWrap && elem) {
|
||||
elem.style.width = (window.innerWidth - 80) + "px";
|
||||
elem.style.height = (window.innerHeight - 80) + "px";
|
||||
elem.style.width = (window.innerWidth - 80) + 'px';
|
||||
elem.style.height = (window.innerHeight - 80) + 'px';
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
elem = document.createElement("iframe");
|
||||
elem.style.width = (window.innerWidth - 80) + "px";
|
||||
elem.style.height = (window.innerHeight - 80) + "px";
|
||||
elem.style.borderWidth = "0px";
|
||||
elem.name = "targetFrame";
|
||||
elem = document.createElement('iframe');
|
||||
elem.style.width = (window.innerWidth - 80) + 'px';
|
||||
elem.style.height = (window.innerHeight - 80) + 'px';
|
||||
elem.style.borderWidth = '0px';
|
||||
elem.name = 'targetFrame';
|
||||
elem.src = strUrl;
|
||||
|
||||
|
||||
window.addEventListener("resize", function () {
|
||||
window.addEventListener('resize', function () {
|
||||
if (browserWrap && elem) {
|
||||
elem.style.width = (window.innerWidth - 80) + "px";
|
||||
elem.style.height = (window.innerHeight - 80) + "px";
|
||||
elem.style.width = (window.innerWidth - 80) + 'px';
|
||||
elem.style.height = (window.innerHeight - 80) + 'px';
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -110,8 +108,7 @@ var IAB = {
|
||||
window.location = strUrl;
|
||||
}
|
||||
|
||||
//var object = new WinJS.UI.HtmlControl(elem, { uri: strUrl });
|
||||
|
||||
// var object = new WinJS.UI.HtmlControl(elem, { uri: strUrl });
|
||||
},
|
||||
|
||||
injectScriptCode: function (code, bCB) {
|
||||
@@ -126,5 +123,4 @@ var IAB = {
|
||||
|
||||
module.exports = IAB;
|
||||
|
||||
|
||||
require("cordova/exec/proxy").add("InAppBrowser", module.exports);
|
||||
require('cordova/exec/proxy').add('InAppBrowser', module.exports);
|
||||
|
||||
Reference in New Issue
Block a user