mirror of
https://github.com/shuto-cn/cordova-plugin-inappbrowser.git
synced 2026-01-26 00:00:04 +08:00
Compare commits
69 Commits
CB-9381cor
...
rel/1.4.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56bb457c5e | ||
|
|
c6ff803113 | ||
|
|
21f4de0e2a | ||
|
|
68054819d8 | ||
|
|
0db344327c | ||
|
|
ea1253963b | ||
|
|
555d55ac8a | ||
|
|
2d836eea0f | ||
|
|
5cbd28edb0 | ||
|
|
98b63cc37e | ||
|
|
4f3b4df7d1 | ||
|
|
234cca4e5b | ||
|
|
bb69b79ca3 | ||
|
|
80c8e56fb0 | ||
|
|
b51a4dc54e | ||
|
|
be1f6076c2 | ||
|
|
f04f37a617 | ||
|
|
df94a6c157 | ||
|
|
1f190d517f | ||
|
|
163f7c5a8f | ||
|
|
b024104a54 | ||
|
|
73ed40fe07 | ||
|
|
4d9e4884dd | ||
|
|
04c05a5e52 | ||
|
|
2e0dc26eaa | ||
|
|
8da5e25eee | ||
|
|
15a57485c6 | ||
|
|
c3ccb694d3 | ||
|
|
212e0a34d8 | ||
|
|
518596a96f | ||
|
|
f326121590 | ||
|
|
fa7c46a316 | ||
|
|
9540f11fcc | ||
|
|
3a1fea5d8b | ||
|
|
2fc2658830 | ||
|
|
ce285e8e06 | ||
|
|
65821f907d | ||
|
|
290ea0ac9c | ||
|
|
542536f790 | ||
|
|
9b576f303b | ||
|
|
52cfd3216a | ||
|
|
8142c73c84 | ||
|
|
bc9036d90a | ||
|
|
1cd9205eb5 | ||
|
|
5451427c98 | ||
|
|
e32b95ccf9 | ||
|
|
682703aa24 | ||
|
|
6815a48408 | ||
|
|
620d92e5c0 | ||
|
|
2c002f0f8d | ||
|
|
214763c76b | ||
|
|
8fb2244432 | ||
|
|
1bc51f9381 | ||
|
|
49757716f5 | ||
|
|
6b99fb96f8 | ||
|
|
1912d12697 | ||
|
|
5a558344fd | ||
|
|
e89f602633 | ||
|
|
790771bb00 | ||
|
|
1afd42aabb | ||
|
|
32743e0eb9 | ||
|
|
89c5ee54e7 | ||
|
|
fee0d4e2d8 | ||
|
|
c08e239143 | ||
|
|
2279aee4ff | ||
|
|
368cbcbc41 | ||
|
|
8175122c03 | ||
|
|
11a2acfd7b | ||
|
|
d9900ba783 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,6 +12,7 @@ Thumbs.db
|
||||
*.swp
|
||||
*.user
|
||||
|
||||
node_modules
|
||||
|
||||
|
||||
|
||||
|
||||
16
.jshintrc
Normal file
16
.jshintrc
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
}
|
||||
4
.travis.yml
Normal file
4
.travis.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- "4.2"
|
||||
@@ -26,8 +26,8 @@ Anyone can contribute to Cordova. And we need your contributions.
|
||||
There are multiple ways to contribute: report bugs, improve the docs, and
|
||||
contribute code.
|
||||
|
||||
For instructions on this, start with the
|
||||
[contribution overview](http://cordova.apache.org/#contribute).
|
||||
For instructions on this, start with the
|
||||
[contribution overview](http://cordova.apache.org/contribute/).
|
||||
|
||||
The details are explained there, but the important items are:
|
||||
- Sign and submit an Apache ICLA (Contributor License Agreement).
|
||||
@@ -35,3 +35,30 @@ The details are explained there, but the important items are:
|
||||
- Run the tests so your patch doesn't break existing functionality.
|
||||
|
||||
We look forward to your contributions!
|
||||
|
||||
The notes on [Commit Workflow](https://github.com/apache/cordova-coho/blob/master/docs/committer-workflow.md#commit-workflow) can be helpful even if you are not a committer.
|
||||
|
||||
## Running plugin tests
|
||||
|
||||
* clone and install [cordova-plugin-test-framework](https://github.com/apache/cordova-plugin-test-framework)
|
||||
```
|
||||
git clone git@github.com:apache/cordova-plugin-test-framework.git
|
||||
```
|
||||
* edit ```cordova-plugin-test-framework/www/assets/index.html``` and add the following line
|
||||
```
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com http://cordova.apache.org http://google.co.uk https://google.co.uk 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
|
||||
```
|
||||
* create test project
|
||||
```
|
||||
cordova create plugintest
|
||||
cd plugintest
|
||||
cordova platform add android
|
||||
cordova plugin add ../cordova-plugin-inappbrowser
|
||||
cordova plugin add ../cordova-plugin-inappbrowser/tests
|
||||
cordova plugin add ../cordova-plugin-test-framework
|
||||
```
|
||||
* edit ```config.xml``` and replace ```<content src="index.html" />``` with ```<content src="cdvtests/index.html" />```
|
||||
* run application
|
||||
```
|
||||
cordova run
|
||||
```
|
||||
|
||||
26
README.md
26
README.md
@@ -17,6 +17,8 @@
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-inappbrowser)
|
||||
|
||||
# cordova-plugin-inappbrowser
|
||||
|
||||
This plugin provides a web browser view that displays when calling `cordova.InAppBrowser.open()`.
|
||||
@@ -54,6 +56,10 @@ 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)
|
||||
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
cordova plugin add cordova-plugin-inappbrowser
|
||||
@@ -96,6 +102,7 @@ instance, or the system browser.
|
||||
- __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.
|
||||
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
|
||||
|
||||
iOS only:
|
||||
|
||||
@@ -106,7 +113,7 @@ instance, or the system browser.
|
||||
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened
|
||||
- __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` or `no` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
|
||||
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
|
||||
- __allowInlineMediaPlayback__: Set to `yes` or `no` to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's `video` element must also include the `webkit-playsinline` attribute (defaults to `no`)
|
||||
- __keyboardDisplayRequiresUserAction__: Set to `yes` or `no` to open the keyboard when form elements receive focus via JavaScript's `focus()` call (defaults to `yes`).
|
||||
- __suppressesIncrementalRendering__: Set to `yes` or `no` to wait until all new view content is received before being rendered (defaults to `no`).
|
||||
@@ -168,6 +175,10 @@ opened with `target='_blank'`. The rules might look like these
|
||||
|
||||
### Windows Quirks
|
||||
|
||||
Windows 8.0, 8.1 and Windows Phone 8.1 don't support remote urls to be opened in the Cordova WebView so remote urls are always showed in the system's web browser if opened with `target='_self'`.
|
||||
|
||||
On Windows 10 if the URL is NOT in the white list and is opened with `target='_self'` it will be showed in the system's web browser instead of InAppBrowser popup.
|
||||
|
||||
Similar to Firefox OS IAB window visual behaviour can be overridden via `inAppBrowserWrap`/`inAppBrowserWrapFullscreen` CSS classes
|
||||
|
||||
### Browser Quirks
|
||||
@@ -189,7 +200,7 @@ The object returned from a call to `cordova.InAppBrowser.open`.
|
||||
- executeScript
|
||||
- insertCSS
|
||||
|
||||
## addEventListener
|
||||
## InAppBrowser.addEventListener
|
||||
|
||||
> Adds a listener for an event from the `InAppBrowser`.
|
||||
|
||||
@@ -235,7 +246,7 @@ The object returned from a call to `cordova.InAppBrowser.open`.
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
ref.addEventListener('loadstart', function(event) { alert(event.url); });
|
||||
|
||||
## removeEventListener
|
||||
## InAppBrowser.removeEventListener
|
||||
|
||||
> Removes a listener for an event from the `InAppBrowser`.
|
||||
|
||||
@@ -269,7 +280,7 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
ref.addEventListener('loadstart', myCallback);
|
||||
ref.removeEventListener('loadstart', myCallback);
|
||||
|
||||
## close
|
||||
## InAppBrowser.close
|
||||
|
||||
> Closes the `InAppBrowser` window.
|
||||
|
||||
@@ -292,7 +303,7 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
ref.close();
|
||||
|
||||
## show
|
||||
## InAppBrowser.show
|
||||
|
||||
> Displays an InAppBrowser window that was opened hidden. Calling this has no effect if the InAppBrowser was already visible.
|
||||
|
||||
@@ -314,7 +325,7 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
// some time later...
|
||||
ref.show();
|
||||
|
||||
## executeScript
|
||||
## InAppBrowser.executeScript
|
||||
|
||||
> Injects JavaScript code into the `InAppBrowser` window
|
||||
|
||||
@@ -356,7 +367,7 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
Due to [MSDN docs](https://msdn.microsoft.com/en-us/library/windows.ui.xaml.controls.webview.invokescriptasync.aspx) the invoked script can return only string values, otherwise the parameter, passed to __callback__ will be `[null]`.
|
||||
|
||||
## insertCSS
|
||||
## InAppBrowser.insertCSS
|
||||
|
||||
> Injects CSS into the `InAppBrowser` window.
|
||||
|
||||
@@ -383,4 +394,3 @@ Due to [MSDN docs](https://msdn.microsoft.com/en-us/library/windows.ui.xaml.cont
|
||||
ref.addEventListener('loadstop', function() {
|
||||
ref.insertCSS({file: "mystyles.css"});
|
||||
});
|
||||
|
||||
|
||||
346
RELEASENOTES.md
346
RELEASENOTES.md
@@ -20,119 +20,113 @@
|
||||
-->
|
||||
# Release Notes
|
||||
|
||||
### 0.2.2 (Sept 25, 2013)
|
||||
* CB-4889 bumping&resetting version
|
||||
* CB-4788: Modified the onJsPrompt to warn against Cordova calls
|
||||
* [windows8] commandProxy was moved
|
||||
* CB-4788: Modified the onJsPrompt to warn against Cordova calls
|
||||
* [windows8] commandProxy was moved
|
||||
* CB-4889 renaming core references
|
||||
* CB-4889 renaming org.apache.cordova.core.inappbrowser to org.apache.cordova.inappbrowser
|
||||
* CB-4864, CB-4865: Minor improvements to InAppBrowser
|
||||
* Rename CHANGELOG.md -> RELEASENOTES.md
|
||||
* [CB-4792] Added keepCallback to the show function.
|
||||
* [CB-4752] Incremented plugin version on dev branch.
|
||||
### 1.4.0 (Apr 15, 2016)
|
||||
* CB-7679 add fix for **iOS** upload.
|
||||
* CB-10944 `NoSuchMethodError` in `InAppBrowser` plugin
|
||||
* CB-10937 fix stretched icons
|
||||
* CB-10760 Fixing README for display on Cordova website
|
||||
* CB-10636 Add `JSHint` for plugins
|
||||
|
||||
### 0.2.3 (Oct 9, 2013)
|
||||
* [CB-4915] Incremented plugin version on dev branch.
|
||||
* [CB-4926] Fixes inappbrowser plugin loading for windows8
|
||||
### 1.3.0 (Feb 09, 2016)
|
||||
* [CB-3360](https://issues.apache.org/jira/browse/CB-3360) Set custom inappbrowser user agent for android
|
||||
* [CB-10538](https://issues.apache.org/jira/browse/CB-10538) cordova-plugin-inappbrowser timeout issue
|
||||
* [CB-10395](https://issues.apache.org/jira/browse/CB-10395) InAppBrowser's WebView not storing cookies reliable on Android
|
||||
* Edit package.json license to match SPDX id
|
||||
* [CB-10305](https://issues.apache.org/jira/browse/CB-10305) Gray bar appears in the wrong place on iOS
|
||||
* [CB-7786](https://issues.apache.org/jira/browse/CB-7786) Support mediaPlaybackRequiresUserAction on Android
|
||||
* [CB-7500](https://issues.apache.org/jira/browse/CB-7500) executeScript with callback kills/blurs inAppBrowser window on Android
|
||||
|
||||
### 0.2.4 (Oct 28, 2013)
|
||||
* CB-5128: added repo + issue tag to plugin.xml for inappbrowser plugin
|
||||
* CB-4995 Fix crash when WebView is quickly opened then closed.
|
||||
* CB-4930 - iOS - InAppBrowser should take into account the status bar
|
||||
* [CB-5010] Incremented plugin version on dev branch.
|
||||
* [CB-5010] Updated version and RELEASENOTES.md for release 0.2.3
|
||||
* CB-4858 - Run IAB methods on the UI thread.
|
||||
* CB-4858 Convert relative URLs to absolute URLs in JS
|
||||
* CB-3747 Fix back button having different dismiss logic from the close button.
|
||||
* CB-5021 Expose closeDialog() as a public function and make it safe to call multiple times.
|
||||
* CB-5021 Make it safe to call close() multiple times
|
||||
### 1.2.1 (Feb 02, 2016)
|
||||
* [CB-10407](https://issues.apache.org/jira/browse/CB-10407) InAppBrowser not firing loadstart event on android
|
||||
* [CB-10428](https://issues.apache.org/jira/browse/CB-10428) Fix syntax error when browserifying inAppBrowser plugin
|
||||
* handle app store urls in system browser
|
||||
* [CB-6702](https://issues.apache.org/jira/browse/CB-6702) InAppBrowser hangs when opening more than one instance
|
||||
* [CB-10456](https://issues.apache.org/jira/browse/CB-10456) InAppBrowser is not closed if I close it programmatically on Android
|
||||
* [CB-10451](https://issues.apache.org/jira/browse/CB-10451) InAppBrowser: loadstart event is not triggered on Windows
|
||||
* [CB-10452](https://issues.apache.org/jira/browse/CB-10452) InAppBrowser: 'exit' event is not triggered on Windows
|
||||
* [CB-10454](https://issues.apache.org/jira/browse/CB-10454) InAppBrowser: 'loaderror' event does not have code and message on Windows
|
||||
* [CB-10450](https://issues.apache.org/jira/browse/CB-10450) InAppBrowser: Unable to get property 'canGoBack' of undefined on Windows
|
||||
* [CB-10441](https://issues.apache.org/jira/browse/CB-10441) Add auto tests for InAppBrowser plugin
|
||||
|
||||
### 0.2.5 (Dec 4, 2013)
|
||||
* Remove merge conflict tag
|
||||
* [CB-4724] fixed UriFormatException
|
||||
* add ubuntu platform
|
||||
* CB-3420 WP feature hidden=yes implemented
|
||||
* Added amazon-fireos platform. Change to use amazon-fireos as the platform if user agent string contains 'cordova-amazon-fireos'
|
||||
### 1.2.0 (Jan 15, 2016)
|
||||
* CB-8180: Changing methods of interception in `WebViewClient` class
|
||||
* CB-10009 Improve `InAppBrowser` toolbar look and feel on **Windows**
|
||||
* Open a new window on the **Browser** platform
|
||||
|
||||
### 0.3.0 (Jan 02, 2014)
|
||||
* CB-5592 Android: Add MIME type to Intent when opening file:/// URLs
|
||||
* CB-5594 iOS: Add disallowoverscroll option.
|
||||
* CB-5658 Add doc/index.md for InAppBrowser plugin
|
||||
* CB-5595 Add toolbarposition=top option.
|
||||
* Apply CB-5193 to InAppBrowser (Fix DB quota exception)
|
||||
* CB-5593 iOS: Make InAppBrowser localizable
|
||||
* CB-5591 Change window.escape to encodeURIComponent
|
||||
### 1.1.1 (Dec 10, 2015)
|
||||
|
||||
### 0.3.1 (Feb 05, 2014)
|
||||
* CB-5756: Android: Use WebView.evaluateJavascript for script injection on Android 4.4+
|
||||
* Didn't test on ICS or lower, getDrawable isn't supported until Jellybean
|
||||
* add ubuntu platform
|
||||
* Adding drawables to the inAppBrowser. This doesn't look quite right, but it's a HUGE improvement over the previous settings
|
||||
* CB-5756: Android: Use WebView.evaluateJavascript for script injection on Android 4.4+
|
||||
* Remove alive from InAppBrowser.js since it didn't catch the case where the browser is closed by the user.
|
||||
* CB-5733 Fix IAB.close() not working if called before show() animation is done
|
||||
* CB-9445 Improves executeScript callbacks on iOS
|
||||
* CB-10035 Incremented plugin version.
|
||||
* CB-10040 - re-fix: backwards compatible with cordova-ios < 4.0
|
||||
* CB-8534: Allow plugins to respond to onReceivedHttpAuthRequest. This closes #82
|
||||
* CB-3750: Fixes spinner on iOS. This closes #89
|
||||
* CB-7696 Document target=_self behavior for Windows
|
||||
* CB-10040 - Compile Error in InAppBrowser Plugin for iOS - No known instance method for selector 'URLIsWhitelisted:'
|
||||
|
||||
### 0.3.2 (Feb 26, 2014)
|
||||
* Validate that callbackId is correctly formed
|
||||
* CB-6035 Move js-module so it is not loaded on unsupported platforms
|
||||
* Removed some iOS6 Deprecations
|
||||
### 1.1.0 (Nov 18, 2015)
|
||||
* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest
|
||||
* Invoke webview if using local file
|
||||
* Fixed `zIndex` issue on **Windows 8**, **8.188 where InAppBrowser opens behind default app.
|
||||
* fix `async` self usage
|
||||
* [CB-9150](https://issues.apache.org/jira/browse/CB-9150) Fix InAppBrowser `executeScript` crash on **Windows** if no data returned
|
||||
* [CB-10008](https://issues.apache.org/jira/browse/CB-10008) Fix InAppBrowser popup layout on **Windows**
|
||||
* Setting `setStatusBarStyle` to `-1` causes `CGContextSaveGState`.
|
||||
* [CB-9167](https://issues.apache.org/jira/browse/CB-9167) Fix crash on **browser** window close
|
||||
* [CB-9799](https://issues.apache.org/jira/browse/CB-9799) Fixed `javaDoc` errors.
|
||||
* Fixing contribute link.
|
||||
* [CB-9760](https://issues.apache.org/jira/browse/CB-9760) InAppBrowser: fallback to default `window.open` behavior on **Ripple**
|
||||
* [CB-9378](https://issues.apache.org/jira/browse/CB-9378) Fix InAppBrowser not taking whole screen on **Windows**
|
||||
* [CB-9158](https://issues.apache.org/jira/browse/CB-9158) - InAppBrowser `zoomControls` are always set to true
|
||||
|
||||
### 0.3.3 (Mar 5, 2014)
|
||||
* CB-5534 Fix video/audio does not stop playing when browser is closed
|
||||
* CB-6172 Fix broken install on case-sensitive file-systems
|
||||
### 1.0.1 (Jun 17, 2015)
|
||||
* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* fix npm md issue
|
||||
|
||||
### 1.0.0 (Apr 15, 2015)
|
||||
* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump
|
||||
* [CB-7689](https://issues.apache.org/jira/browse/CB-7689) Adds insertCSS support for windows platform
|
||||
* [CB-4930](https://issues.apache.org/jira/browse/CB-4930) - (prefix) InAppBrowser should take into account the status bar
|
||||
* [CB-8635](https://issues.apache.org/jira/browse/CB-8635) Improves UX on windows platform
|
||||
* [CB-8661](https://issues.apache.org/jira/browse/CB-8661) Return executed script result on Windows
|
||||
* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) updated wp and browser specific references of old id to new id
|
||||
* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id
|
||||
* Use TRAVIS_BUILD_DIR, install paramedic by npm
|
||||
* [CB-8432](https://issues.apache.org/jira/browse/CB-8432) Correct styles for browser wrapper to display it correctly on some pages
|
||||
* [CB-8659](https://issues.apache.org/jira/browse/CB-8659) - Update InAppBrowser to support both cordova-ios 4.0.x and 3.x (closes #93)
|
||||
* [CB-7961](https://issues.apache.org/jira/browse/CB-7961) Add cordova-plugin-inappbrowser support for browser platform
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme
|
||||
* Update docs for Android zoom=no option
|
||||
* Added option to disable/enable zoom controls
|
||||
* updated docs, set hardwareback default to true
|
||||
* Add a hardwareback option to allow for the hardware back button to go back.
|
||||
* [CB-8570](https://issues.apache.org/jira/browse/CB-8570) Integrate TravisCI
|
||||
* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file
|
||||
* Keep external android pages in a single tab. (close #61)
|
||||
* [CB-8444](https://issues.apache.org/jira/browse/CB-8444) Add a clobber for `cordova.InAppBrowser.open` (close #80)
|
||||
* [CB-8444](https://issues.apache.org/jira/browse/CB-8444) Don't clobber `window.open` - Add new symbol/clobber to access open function (`cordova.InAppBrowser.open`) - Change existing tests to use new symbol (i.e. don't rely on plugin clobber of `window.open`) - Add tests to use `window.open` via manual replace with new symbol - Update docs to deprecate plugin clobber of `window.open`
|
||||
|
||||
### 0.4.0 (Apr 17, 2014)
|
||||
* CB-6360: [ios] Fix for crash on iOS < 6.0 (closes #37)
|
||||
* CB-3324: [WP8] Add support for back-button inappbrowser [WP8] if there is no history -> InAppBrowser is closed
|
||||
* [WP] await async calls, resolve warnings
|
||||
* [WP] Make InAppBrowser work with embedded files, using system behavior
|
||||
* CB-6402: [WP8] pass empty string instead of null for [optional] windowFeatures string
|
||||
* CB-6422: [windows8] use cordova/exec/proxy
|
||||
* CB-6389 CB-3617: Add clearcache and clearsessioncache options to iOS (like Android)
|
||||
* Doc update: event name and example param (closes #31)
|
||||
* CB-6253: [WP] Add Network Capability to WMAppManifest.xml
|
||||
* CB-6212: [iOS] fix warnings compiled under arm64 64-bit
|
||||
* CB-6218: Update docs for BB10
|
||||
* CB-6460: Update license headers
|
||||
### 0.6.0 (Feb 04, 2015)
|
||||
* [CB-8270](https://issues.apache.org/jira/browse/CB-8270) ios: Remove usage of `[arr JSONString]`, since it's been renamed to `cdv_JSONString`
|
||||
* ubuntu: implement `inject*` functions
|
||||
* ubuntu: port to oxide
|
||||
* [CB-7897](https://issues.apache.org/jira/browse/CB-7897) ios, android: Update to work with whilelist plugins in Cordova 4.x
|
||||
|
||||
### 0.5.0 (Jun 05, 2014)
|
||||
* CB-6127 Spanish and rench Translations added. Github close #23
|
||||
* Clean up whitespace (mainly due to no newline at eof warning)
|
||||
* Adding permission info
|
||||
* CB-6806 Add license
|
||||
* CB-6491 add CONTRIBUTING.md
|
||||
* Add necessary capability so the plugin works on its own
|
||||
* CB-6474 InAppBrowser. Add data urls support to WP8
|
||||
* CB-6482 InAppBrowser calls incorrect callback on WP8
|
||||
* Fixed use of iOS 6 deprecated methods
|
||||
* CB-6360 - improvement: feature detection instead of iOS version detection
|
||||
* CB-5649 - InAppBrowser overrides App's orientation
|
||||
* refactoring fixed
|
||||
* CB-6396 [Firefox OS] Adding basic support
|
||||
|
||||
### 0.5.1 (Aug 06, 2014)
|
||||
* ubuntu: support qt 5.2
|
||||
* **FFOS** update InAppBrowserProxy.js
|
||||
* **FFOS** app needs to be privileged
|
||||
* CB-6127 Updated translations for docs
|
||||
* CB-6769 ios: Fix statusbar color reset wasn't working on iOS7+
|
||||
|
||||
### 0.5.2 (Sep 17, 2014)
|
||||
* CB-7471 cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* CB-7490 Fixes InAppBrowser manual tests crash on windows platform
|
||||
* CB-7249 cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* CB-7424 Wrong docs: anchor tags are not supported by the InAppBrowser
|
||||
* CB-7133 clarify that anchor1 doesn't exist
|
||||
* CB-7133 more fixup of tests on Android
|
||||
* CB-7133 fix up the tests for Android
|
||||
* Add just a bit more logging
|
||||
* CB-7133 port inappbrowser to plugin-test-framework
|
||||
* phonegap events supported for \_blank target
|
||||
* inappbrowser \_blank target position is fixed
|
||||
* amazon-fireos related changes.
|
||||
### 0.5.4 (Dec 02, 2014)
|
||||
* [CB-7784](https://issues.apache.org/jira/browse/CB-7784) Exit event is not fired after `InAppBrowser` closing
|
||||
* [CB-7697](https://issues.apache.org/jira/browse/CB-7697) Add `locationBar` support to `InAppBrowser` **Windows** platform version
|
||||
* [CB-7690](https://issues.apache.org/jira/browse/CB-7690) `InAppBrowser` `loadstart/loadstop` events issues
|
||||
* [CB-7695](https://issues.apache.org/jira/browse/CB-7695) Fix `InAppBrowser` `injectScriptFile` for **Windows 8.1** / **Windows Phone 8.1**
|
||||
* [CB-7692](https://issues.apache.org/jira/browse/CB-7692) `InAppBrowser` local url opening bug in 8.1
|
||||
* [CB-7688](https://issues.apache.org/jira/browse/CB-7688) `Alert` is not supported in `InAppBrowser` on **Windows** platform
|
||||
* [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention `deviceready` in plugin docs
|
||||
* [CB-7876](https://issues.apache.org/jira/browse/CB-7876) change test target to avoid undesired redirects
|
||||
* [CB-7712](https://issues.apache.org/jira/browse/CB-7712) remove references to `closebuttoncaption`
|
||||
* [CB-7850](https://issues.apache.org/jira/browse/CB-7850) clarify role of whitelist
|
||||
* [CB-7720](https://issues.apache.org/jira/browse/CB-7720) check if event is null since OK string from success callback was removed
|
||||
* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
|
||||
### 0.5.3 (Oct 03, 2014)
|
||||
* Windows implementation fixes and improvements
|
||||
@@ -145,52 +139,106 @@
|
||||
* Append Windows 8.1 platform configuration in plugin.xml
|
||||
* Append Windows 8.1 proxy using x-ms-webview
|
||||
|
||||
### 0.5.4 (Dec 02, 2014)
|
||||
* CB-7784 Exit event is not fired after `InAppBrowser` closing
|
||||
* CB-7697 Add `locationBar` support to `InAppBrowser` **Windows** platform version
|
||||
* CB-7690 `InAppBrowser` `loadstart/loadstop` events issues
|
||||
* CB-7695 Fix `InAppBrowser` `injectScriptFile` for **Windows 8.1** / **Windows Phone 8.1**
|
||||
* CB-7692 `InAppBrowser` local url opening bug in 8.1
|
||||
* CB-7688 `Alert` is not supported in `InAppBrowser` on **Windows** platform
|
||||
* CB-7977 Mention `deviceready` in plugin docs
|
||||
* CB-7876 change test target to avoid undesired redirects
|
||||
* CB-7712 remove references to `closebuttoncaption`
|
||||
* CB-7850 clarify role of whitelist
|
||||
* CB-7720 check if event is null since OK string from success callback was removed
|
||||
* CB-7471 cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
### 0.5.2 (Sep 17, 2014)
|
||||
* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* [CB-7490](https://issues.apache.org/jira/browse/CB-7490) Fixes InAppBrowser manual tests crash on windows platform
|
||||
* [CB-7249](https://issues.apache.org/jira/browse/CB-7249) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* [CB-7424](https://issues.apache.org/jira/browse/CB-7424) Wrong docs: anchor tags are not supported by the InAppBrowser
|
||||
* [CB-7133](https://issues.apache.org/jira/browse/CB-7133) clarify that anchor1 doesn't exist
|
||||
* [CB-7133](https://issues.apache.org/jira/browse/CB-7133) more fixup of tests on Android
|
||||
* [CB-7133](https://issues.apache.org/jira/browse/CB-7133) fix up the tests for Android
|
||||
* Add just a bit more logging
|
||||
* [CB-7133](https://issues.apache.org/jira/browse/CB-7133) port inappbrowser to plugin-test-framework
|
||||
* phonegap events supported for \_blank target
|
||||
* inappbrowser \_blank target position is fixed
|
||||
* amazon-fireos related changes.
|
||||
|
||||
### 0.6.0 (Feb 04, 2015)
|
||||
* CB-8270 ios: Remove usage of `[arr JSONString]`, since it's been renamed to `cdv_JSONString`
|
||||
* ubuntu: implement inject* functions
|
||||
* ubuntu: port to oxide
|
||||
* CB-7897 ios, android: Update to work with whilelist plugins in Cordova 4.x
|
||||
### 0.5.1 (Aug 06, 2014)
|
||||
* ubuntu: support qt 5.2
|
||||
* **FFOS** update InAppBrowserProxy.js
|
||||
* **FFOS** app needs to be privileged
|
||||
* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs
|
||||
* [CB-6769](https://issues.apache.org/jira/browse/CB-6769) ios: Fix statusbar color reset wasn't working on iOS7+
|
||||
|
||||
### 1.0.0 (Apr 15, 2015)
|
||||
* CB-8746 gave plugin major version bump
|
||||
* CB-7689 Adds insertCSS support for windows platform
|
||||
* CB-4930 - (prefix) InAppBrowser should take into account the status bar
|
||||
* CB-8635 Improves UX on windows platform
|
||||
* CB-8661 Return executed script result on Windows
|
||||
* CB-8683 updated wp and browser specific references of old id to new id
|
||||
* CB-8683 changed plugin-id to pacakge-name
|
||||
* CB-8653 properly updated translated docs to use new id
|
||||
* CB-8653 updated translated docs to use new id
|
||||
* Use TRAVIS_BUILD_DIR, install paramedic by npm
|
||||
* CB-8432 Correct styles for browser wrapper to display it correctly on some pages
|
||||
* CB-8659 - Update InAppBrowser to support both cordova-ios 4.0.x and 3.x (closes #93)
|
||||
* CB-7961 Add cordova-plugin-inappbrowser support for browser platform
|
||||
* CB-8653 Updated Readme
|
||||
* Update docs for Android zoom=no option
|
||||
* Added option to disable/enable zoom controls
|
||||
* updated docs, set hardwareback default to true
|
||||
* Add a hardwareback option to allow for the hardware back button to go back.
|
||||
* CB-8570 Integrate TravisCI
|
||||
* CB-8438 cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* CB-8538 Added package.json file
|
||||
* Keep external android pages in a single tab. (close #61)
|
||||
* CB-8444 Add a clobber for `cordova.InAppBrowser.open` (close #80)
|
||||
* CB-8444 Don't clobber `window.open` - Add new symbol/clobber to access open function (`cordova.InAppBrowser.open`) - Change existing tests to use new symbol (i.e. don't rely on plugin clobber of `window.open`) - Add tests to use `window.open` via manual replace with new symbol - Update docs to deprecate plugin clobber of `window.open`
|
||||
### 0.5.0 (Jun 05, 2014)
|
||||
* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Spanish and rench Translations added. Github close #23
|
||||
* Clean up whitespace (mainly due to no newline at eof warning)
|
||||
* Adding permission info
|
||||
* [CB-6806](https://issues.apache.org/jira/browse/CB-6806) Add license
|
||||
* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md
|
||||
* Add necessary capability so the plugin works on its own
|
||||
* [CB-6474](https://issues.apache.org/jira/browse/CB-6474) InAppBrowser. Add data urls support to WP8
|
||||
* [CB-6482](https://issues.apache.org/jira/browse/CB-6482) InAppBrowser calls incorrect callback on WP8
|
||||
* Fixed use of iOS 6 deprecated methods
|
||||
* [CB-6360](https://issues.apache.org/jira/browse/CB-6360) - improvement: feature detection instead of iOS version detection
|
||||
* [CB-5649](https://issues.apache.org/jira/browse/CB-5649) - InAppBrowser overrides App's orientation
|
||||
* refactoring fixed
|
||||
* [CB-6396](https://issues.apache.org/jira/browse/CB-6396) [Firefox OS] Adding basic support
|
||||
|
||||
### 1.0.1 (Jun 17, 2015)
|
||||
* CB-9128 cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* fix npm md issue
|
||||
### 0.4.0 (Apr 17, 2014)
|
||||
* [CB-6360](https://issues.apache.org/jira/browse/CB-6360): [ios] Fix for crash on iOS < 6.0 (closes #37)
|
||||
* [CB-3324](https://issues.apache.org/jira/browse/CB-3324): [WP8] Add support for back-button inappbrowser [WP8] if there is no history -> InAppBrowser is closed
|
||||
* [WP] await async calls, resolve warnings
|
||||
* [WP] Make InAppBrowser work with embedded files, using system behavior
|
||||
* [CB-6402](https://issues.apache.org/jira/browse/CB-6402): [WP8] pass empty string instead of null for [optional] windowFeatures string
|
||||
* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy
|
||||
* [CB-6389](https://issues.apache.org/jira/browse/CB-6389) [CB-3617](https://issues.apache.org/jira/browse/CB-3617): Add clearcache and clearsessioncache options to iOS (like Android)
|
||||
* Doc update: event name and example param (closes #31)
|
||||
* [CB-6253](https://issues.apache.org/jira/browse/CB-6253): [WP] Add Network Capability to WMAppManifest.xml
|
||||
* [CB-6212](https://issues.apache.org/jira/browse/CB-6212): [iOS] fix warnings compiled under arm64 64-bit
|
||||
* [CB-6218](https://issues.apache.org/jira/browse/CB-6218): Update docs for BB10
|
||||
* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers
|
||||
|
||||
### 0.3.3 (Mar 5, 2014)
|
||||
* [CB-5534](https://issues.apache.org/jira/browse/CB-5534) Fix video/audio does not stop playing when browser is closed
|
||||
* [CB-6172](https://issues.apache.org/jira/browse/CB-6172) Fix broken install on case-sensitive file-systems
|
||||
|
||||
### 0.3.2 (Feb 26, 2014)
|
||||
* Validate that callbackId is correctly formed
|
||||
* [CB-6035](https://issues.apache.org/jira/browse/CB-6035) Move js-module so it is not loaded on unsupported platforms
|
||||
* Removed some iOS6 Deprecations
|
||||
|
||||
### 0.3.1 (Feb 05, 2014)
|
||||
* [CB-5756](https://issues.apache.org/jira/browse/CB-5756): Android: Use WebView.evaluateJavascript for script injection on Android 4.4+
|
||||
* Didn't test on ICS or lower, getDrawable isn't supported until Jellybean
|
||||
* add ubuntu platform
|
||||
* Adding drawables to the inAppBrowser. This doesn't look quite right, but it's a HUGE improvement over the previous settings
|
||||
* [CB-5756](https://issues.apache.org/jira/browse/CB-5756): Android: Use WebView.evaluateJavascript for script injection on Android 4.4+
|
||||
* Remove alive from InAppBrowser.js since it didn't catch the case where the browser is closed by the user.
|
||||
* [CB-5733](https://issues.apache.org/jira/browse/CB-5733) Fix IAB.close() not working if called before show() animation is done
|
||||
|
||||
### 0.2.5 (Dec 4, 2013)
|
||||
* Remove merge conflict tag
|
||||
* [CB-4724](https://issues.apache.org/jira/browse/CB-4724) fixed UriFormatException
|
||||
* add ubuntu platform
|
||||
* [CB-3420](https://issues.apache.org/jira/browse/CB-3420) WP feature hidden=yes implemented
|
||||
* Added amazon-fireos platform. Change to use amazon-fireos as the platform if user agent string contains 'cordova-amazon-fireos'
|
||||
|
||||
### 0.2.4 (Oct 28, 2013)
|
||||
* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): added repo + issue tag to plugin.xml for inappbrowser plugin
|
||||
* [CB-4995](https://issues.apache.org/jira/browse/CB-4995) Fix crash when WebView is quickly opened then closed.
|
||||
* [CB-4930](https://issues.apache.org/jira/browse/CB-4930) - iOS - InAppBrowser should take into account the status bar
|
||||
* [CB-5010](https://issues.apache.org/jira/browse/CB-5010) Incremented plugin version on dev branch.
|
||||
* [CB-5010](https://issues.apache.org/jira/browse/CB-5010) Updated version and RELEASENOTES.md for release 0.2.3
|
||||
* [CB-4858](https://issues.apache.org/jira/browse/CB-4858) - Run IAB methods on the UI thread.
|
||||
* [CB-4858](https://issues.apache.org/jira/browse/CB-4858) Convert relative URLs to absolute URLs in JS
|
||||
* [CB-3747](https://issues.apache.org/jira/browse/CB-3747) Fix back button having different dismiss logic from the close button.
|
||||
* [CB-5021](https://issues.apache.org/jira/browse/CB-5021) Expose closeDialog() as a public function and make it safe to call multiple times.
|
||||
* [CB-5021](https://issues.apache.org/jira/browse/CB-5021) Make it safe to call close() multiple times
|
||||
|
||||
### 0.2.3 (Oct 9, 2013)
|
||||
* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch.
|
||||
* [CB-4926](https://issues.apache.org/jira/browse/CB-4926) Fixes inappbrowser plugin loading for windows8
|
||||
|
||||
### 0.2.2 (Sept 25, 2013)
|
||||
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version
|
||||
* [CB-4788](https://issues.apache.org/jira/browse/CB-4788): Modified the onJsPrompt to warn against Cordova calls
|
||||
* [windows8] commandProxy was moved
|
||||
* [CB-4788](https://issues.apache.org/jira/browse/CB-4788): Modified the onJsPrompt to warn against Cordova calls
|
||||
* [windows8] commandProxy was moved
|
||||
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming core references
|
||||
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.inappbrowser to org.apache.cordova.inappbrowser
|
||||
* [CB-4864](https://issues.apache.org/jira/browse/CB-4864), [CB-4865](https://issues.apache.org/jira/browse/CB-4865): Minor improvements to InAppBrowser
|
||||
* Rename CHANGELOG.md -> RELEASENOTES.md
|
||||
* [CB-4792](https://issues.apache.org/jira/browse/CB-4792) Added keepCallback to the show function.
|
||||
* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch.
|
||||
|
||||
11
package.json
11
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cordova-plugin-inappbrowser",
|
||||
"version": "1.0.2-dev",
|
||||
"version": "1.4.0",
|
||||
"description": "Cordova InAppBrowser Plugin",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-inappbrowser",
|
||||
@@ -37,6 +37,10 @@
|
||||
"cordova-windows",
|
||||
"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"
|
||||
},
|
||||
"engines": [
|
||||
{
|
||||
"name": "cordova",
|
||||
@@ -44,5 +48,8 @@
|
||||
}
|
||||
],
|
||||
"author": "Apache Software Foundation",
|
||||
"license": "Apache 2.0"
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"jshint": "^2.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-inappbrowser"
|
||||
version="1.0.2-dev">
|
||||
version="1.4.0">
|
||||
|
||||
<name>InAppBrowser</name>
|
||||
<description>Cordova InAppBrowser Plugin</description>
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package org.apache.cordova.inappbrowser;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import org.apache.cordova.inappbrowser.InAppBrowserDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.Browser;
|
||||
@@ -41,17 +40,21 @@ import android.view.WindowManager.LayoutParams;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.CookieSyncManager;
|
||||
import android.webkit.HttpAuthHandler;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.Config;
|
||||
import org.apache.cordova.CordovaArgs;
|
||||
import org.apache.cordova.CordovaHttpAuthHandler;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.apache.cordova.LOG;
|
||||
@@ -61,6 +64,7 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.StringTokenizer;
|
||||
@@ -72,7 +76,6 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
protected static final String LOG_TAG = "InAppBrowser";
|
||||
private static final String SELF = "_self";
|
||||
private static final String SYSTEM = "_system";
|
||||
// private static final String BLANK = "_blank";
|
||||
private static final String EXIT_EVENT = "exit";
|
||||
private static final String LOCATION = "location";
|
||||
private static final String ZOOM = "zoom";
|
||||
@@ -83,6 +86,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
private static final String CLEAR_ALL_CACHE = "clearcache";
|
||||
private static final String CLEAR_SESSION_CACHE = "clearsessioncache";
|
||||
private static final String HARDWARE_BACK_BUTTON = "hardwareback";
|
||||
private static final String MEDIA_PLAYBACK_REQUIRES_USER_ACTION = "mediaPlaybackRequiresUserAction";
|
||||
|
||||
private InAppBrowserDialog dialog;
|
||||
private WebView inAppWebView;
|
||||
@@ -94,14 +98,15 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
private boolean clearAllCache = false;
|
||||
private boolean clearSessionCache = false;
|
||||
private boolean hadwareBackButton = true;
|
||||
private boolean mediaPlaybackRequiresUserGesture = false;
|
||||
|
||||
/**
|
||||
* Executes the request and returns PluginResult.
|
||||
*
|
||||
* @param action The action to execute.
|
||||
* @param args JSONArry of arguments for the plugin.
|
||||
* @param callbackId The callback id used when calling back into JavaScript.
|
||||
* @return A PluginResult object with a status and message.
|
||||
* @param action the action to execute.
|
||||
* @param args JSONArry of arguments for the plugin.
|
||||
* @param callbackContext the callbackContext used when calling back into JavaScript.
|
||||
* @return A PluginResult object with a status and message.
|
||||
*/
|
||||
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
|
||||
if (action.equals("open")) {
|
||||
@@ -198,7 +203,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
else if (action.equals("injectScriptCode")) {
|
||||
String jsWrapper = null;
|
||||
if (args.getBoolean(1)) {
|
||||
jsWrapper = String.format("prompt(JSON.stringify([eval(%%s)]), 'gap-iab://%s')", callbackContext.getCallbackId());
|
||||
jsWrapper = String.format("(function(){prompt(JSON.stringify([eval(%%s)]), 'gap-iab://%s')})()", callbackContext.getCallbackId());
|
||||
}
|
||||
injectDeferredObject(args.getString(0), jsWrapper);
|
||||
}
|
||||
@@ -332,9 +337,8 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
/**
|
||||
* Display a new browser with the specified URL.
|
||||
*
|
||||
* @param url The url to load.
|
||||
* @param usePhoneGap Load url in PhoneGap webview
|
||||
* @return "" if ok, or error message.
|
||||
* @param url the url to load.
|
||||
* @return "" if ok, or error message.
|
||||
*/
|
||||
public String openExternal(String url) {
|
||||
try {
|
||||
@@ -361,20 +365,22 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
* Closes the dialog
|
||||
*/
|
||||
public void closeDialog() {
|
||||
final WebView childView = this.inAppWebView;
|
||||
// The JS protects against multiple calls, so this should happen only when
|
||||
// closeDialog() is called by other native code.
|
||||
if (childView == null) {
|
||||
return;
|
||||
}
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final WebView childView = inAppWebView;
|
||||
// The JS protects against multiple calls, so this should happen only when
|
||||
// closeDialog() is called by other native code.
|
||||
if (childView == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
childView.setWebViewClient(new WebViewClient() {
|
||||
// NB: wait for about:blank before dismissing
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
dialog = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -382,16 +388,16 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
// other than your app's UI thread, it can cause unexpected results."
|
||||
// http://developer.android.com/guide/webapps/migrating.html#Threads
|
||||
childView.loadUrl("about:blank");
|
||||
|
||||
try {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("type", EXIT_EVENT);
|
||||
sendUpdate(obj, false);
|
||||
} catch (JSONException ex) {
|
||||
Log.d(LOG_TAG, "Should never happen");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("type", EXIT_EVENT);
|
||||
sendUpdate(obj, false);
|
||||
} catch (JSONException ex) {
|
||||
Log.d(LOG_TAG, "Should never happen");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -462,14 +468,16 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
/**
|
||||
* Display a new browser with the specified URL.
|
||||
*
|
||||
* @param url The url to load.
|
||||
* @param jsonObject
|
||||
* @param url the url to load.
|
||||
* @param features jsonObject
|
||||
*/
|
||||
public String showWebPage(final String url, HashMap<String, Boolean> features) {
|
||||
// Determine if we should hide the location bar.
|
||||
showLocationBar = true;
|
||||
showZoomControls = true;
|
||||
openWindowHidden = false;
|
||||
mediaPlaybackRequiresUserGesture = false;
|
||||
|
||||
if (features != null) {
|
||||
Boolean show = features.get(LOCATION);
|
||||
if (show != null) {
|
||||
@@ -487,6 +495,10 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
if (hardwareBack != null) {
|
||||
hadwareBackButton = hardwareBack.booleanValue();
|
||||
}
|
||||
Boolean mediaPlayback = features.get(MEDIA_PLAYBACK_REQUIRES_USER_ACTION);
|
||||
if (mediaPlayback != null) {
|
||||
mediaPlaybackRequiresUserGesture = mediaPlayback.booleanValue();
|
||||
}
|
||||
Boolean cache = features.get(CLEAR_ALL_CACHE);
|
||||
if (cache != null) {
|
||||
clearAllCache = cache.booleanValue();
|
||||
@@ -518,6 +530,12 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public void run() {
|
||||
|
||||
// CB-6702 InAppBrowser hangs when opening more than one instance
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
};
|
||||
|
||||
// Let's create the main dialog
|
||||
dialog = new InAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
|
||||
dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
|
||||
@@ -543,26 +561,24 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
actionButtonContainer.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
||||
actionButtonContainer.setHorizontalGravity(Gravity.LEFT);
|
||||
actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL);
|
||||
actionButtonContainer.setId(1);
|
||||
actionButtonContainer.setId(Integer.valueOf(1));
|
||||
|
||||
// Back button
|
||||
Button back = new Button(cordova.getActivity());
|
||||
ImageButton back = new ImageButton(cordova.getActivity());
|
||||
RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT);
|
||||
back.setLayoutParams(backLayoutParams);
|
||||
back.setContentDescription("Back Button");
|
||||
back.setId(2);
|
||||
back.setId(Integer.valueOf(2));
|
||||
Resources activityRes = cordova.getActivity().getResources();
|
||||
int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName());
|
||||
Drawable backIcon = activityRes.getDrawable(backResId);
|
||||
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
|
||||
{
|
||||
back.setBackgroundDrawable(backIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
back.setBackground(backIcon);
|
||||
}
|
||||
back.setBackground(null);
|
||||
back.setImageDrawable(backIcon);
|
||||
back.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
|
||||
back.getAdjustViewBounds();
|
||||
|
||||
back.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
goBack();
|
||||
@@ -570,22 +586,20 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
});
|
||||
|
||||
// Forward button
|
||||
Button forward = new Button(cordova.getActivity());
|
||||
ImageButton forward = new ImageButton(cordova.getActivity());
|
||||
RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2);
|
||||
forward.setLayoutParams(forwardLayoutParams);
|
||||
forward.setContentDescription("Forward Button");
|
||||
forward.setId(3);
|
||||
forward.setId(Integer.valueOf(3));
|
||||
int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName());
|
||||
Drawable fwdIcon = activityRes.getDrawable(fwdResId);
|
||||
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
|
||||
{
|
||||
forward.setBackgroundDrawable(fwdIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
forward.setBackground(fwdIcon);
|
||||
}
|
||||
forward.setBackground(null);
|
||||
forward.setImageDrawable(fwdIcon);
|
||||
forward.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
forward.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
|
||||
forward.getAdjustViewBounds();
|
||||
|
||||
forward.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
goForward();
|
||||
@@ -598,7 +612,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1);
|
||||
textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5);
|
||||
edittext.setLayoutParams(textLayoutParams);
|
||||
edittext.setId(4);
|
||||
edittext.setId(Integer.valueOf(4));
|
||||
edittext.setSingleLine(true);
|
||||
edittext.setText(url);
|
||||
edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
|
||||
@@ -616,22 +630,20 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
});
|
||||
|
||||
// Close/Done button
|
||||
Button close = new Button(cordova.getActivity());
|
||||
ImageButton close = new ImageButton(cordova.getActivity());
|
||||
RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
close.setLayoutParams(closeLayoutParams);
|
||||
forward.setContentDescription("Close Button");
|
||||
close.setId(5);
|
||||
close.setId(Integer.valueOf(5));
|
||||
int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName());
|
||||
Drawable closeIcon = activityRes.getDrawable(closeResId);
|
||||
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
|
||||
{
|
||||
close.setBackgroundDrawable(closeIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
close.setBackground(closeIcon);
|
||||
}
|
||||
close.setBackground(null);
|
||||
close.setImageDrawable(closeIcon);
|
||||
close.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
|
||||
close.getAdjustViewBounds();
|
||||
|
||||
close.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
closeDialog();
|
||||
@@ -641,6 +653,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
// WebView
|
||||
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));
|
||||
WebViewClient client = new InAppBrowserClient(thatWebView, edittext);
|
||||
inAppWebView.setWebViewClient(client);
|
||||
@@ -650,6 +663,20 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
settings.setBuiltInZoomControls(showZoomControls);
|
||||
settings.setPluginState(android.webkit.WebSettings.PluginState.ON);
|
||||
|
||||
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
settings.setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture);
|
||||
}
|
||||
|
||||
String overrideUserAgent = preferences.getString("OverrideUserAgent", null);
|
||||
String appendUserAgent = preferences.getString("AppendUserAgent", null);
|
||||
|
||||
if (overrideUserAgent != null) {
|
||||
settings.setUserAgentString(overrideUserAgent);
|
||||
}
|
||||
if (appendUserAgent != null) {
|
||||
settings.setUserAgentString(settings.getUserAgentString() + appendUserAgent);
|
||||
}
|
||||
|
||||
//Toggle whether this is enabled or not!
|
||||
Bundle appSettings = cordova.getActivity().getIntent().getExtras();
|
||||
boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true);
|
||||
@@ -667,7 +694,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
}
|
||||
|
||||
inAppWebView.loadUrl(url);
|
||||
inAppWebView.setId(6);
|
||||
inAppWebView.setId(Integer.valueOf(6));
|
||||
inAppWebView.getSettings().setLoadWithOverviewMode(true);
|
||||
inAppWebView.getSettings().setUseWideViewPort(true);
|
||||
inAppWebView.requestFocus();
|
||||
@@ -746,8 +773,8 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param mContext
|
||||
* @param edittext
|
||||
* @param webView
|
||||
* @param mEditText
|
||||
*/
|
||||
public InAppBrowserClient(CordovaWebView webView, EditText mEditText) {
|
||||
this.webView = webView;
|
||||
@@ -755,34 +782,30 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the host application that a page has started loading.
|
||||
* Override the URL that should be loaded
|
||||
*
|
||||
* @param view The webview initiating the callback.
|
||||
* @param url The url of the page.
|
||||
* This handles a small subset of all the URIs that would be encountered.
|
||||
*
|
||||
* @param webView
|
||||
* @param url
|
||||
*/
|
||||
@Override
|
||||
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
||||
super.onPageStarted(view, url, favicon);
|
||||
String newloc = "";
|
||||
if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) {
|
||||
newloc = url;
|
||||
}
|
||||
// If dialing phone (tel:5551212)
|
||||
else if (url.startsWith(WebView.SCHEME_TEL)) {
|
||||
public boolean shouldOverrideUrlLoading(WebView webView, String url) {
|
||||
if (url.startsWith(WebView.SCHEME_TEL)) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_DIAL);
|
||||
intent.setData(Uri.parse(url));
|
||||
cordova.getActivity().startActivity(intent);
|
||||
return true;
|
||||
} catch (android.content.ActivityNotFoundException e) {
|
||||
LOG.e(LOG_TAG, "Error dialing " + url + ": " + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
else if (url.startsWith("geo:") || url.startsWith(WebView.SCHEME_MAILTO) || url.startsWith("market:")) {
|
||||
} else if (url.startsWith("geo:") || url.startsWith(WebView.SCHEME_MAILTO) || url.startsWith("market:")) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(url));
|
||||
cordova.getActivity().startActivity(intent);
|
||||
return true;
|
||||
} catch (android.content.ActivityNotFoundException e) {
|
||||
LOG.e(LOG_TAG, "Error with " + url + ": " + e.toString());
|
||||
}
|
||||
@@ -797,8 +820,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
int parmIndex = url.indexOf('?');
|
||||
if (parmIndex == -1) {
|
||||
address = url.substring(4);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
address = url.substring(4, parmIndex);
|
||||
|
||||
// If body, then set sms body
|
||||
@@ -814,32 +836,64 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
intent.putExtra("address", address);
|
||||
intent.setType("vnd.android-dir/mms-sms");
|
||||
cordova.getActivity().startActivity(intent);
|
||||
return true;
|
||||
} catch (android.content.ActivityNotFoundException e) {
|
||||
LOG.e(LOG_TAG, "Error sending sms " + url + ":" + e.toString());
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* onPageStarted fires the LOAD_START_EVENT
|
||||
*
|
||||
* @param view
|
||||
* @param url
|
||||
* @param favicon
|
||||
*/
|
||||
@Override
|
||||
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
||||
super.onPageStarted(view, url, favicon);
|
||||
String newloc = "";
|
||||
if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) {
|
||||
newloc = url;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume that everything is HTTP at this point, because if we don't specify,
|
||||
// it really should be. Complain loudly about this!!!
|
||||
LOG.e(LOG_TAG, "Possible Uncaught/Unknown URI");
|
||||
newloc = "http://" + url;
|
||||
}
|
||||
|
||||
// Update the UI if we haven't already
|
||||
if (!newloc.equals(edittext.getText().toString())) {
|
||||
edittext.setText(newloc);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("type", LOAD_START_EVENT);
|
||||
obj.put("url", newloc);
|
||||
|
||||
sendUpdate(obj, true);
|
||||
} catch (JSONException ex) {
|
||||
Log.d(LOG_TAG, "Should never happen");
|
||||
LOG.e(LOG_TAG, "URI passed in has caused a JSON error.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
super.onPageFinished(view, url);
|
||||
|
||||
// CB-10395 InAppBrowser's WebView not storing cookies reliable to local device storage
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
CookieManager.getInstance().flush();
|
||||
} else {
|
||||
CookieSyncManager.getInstance().sync();
|
||||
}
|
||||
|
||||
try {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("type", LOAD_STOP_EVENT);
|
||||
@@ -866,5 +920,38 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
Log.d(LOG_TAG, "Should never happen");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On received http auth request.
|
||||
*/
|
||||
@Override
|
||||
public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
|
||||
|
||||
// Check if there is some plugin which can resolve this auth challenge
|
||||
PluginManager pluginManager = null;
|
||||
try {
|
||||
Method gpm = webView.getClass().getMethod("getPluginManager");
|
||||
pluginManager = (PluginManager)gpm.invoke(webView);
|
||||
} catch (NoSuchMethodException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
|
||||
if (pluginManager == null) {
|
||||
try {
|
||||
Field pmf = webView.getClass().getField("pluginManager");
|
||||
pluginManager = (PluginManager)pmf.get(webView);
|
||||
} catch (NoSuchFieldException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (pluginManager != null && pluginManager.onReceivedHttpAuthRequest(webView, new CordovaHttpAuthHandler(handler), host, realm)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// By default handle 401 like we'd normally do!
|
||||
super.onReceivedHttpAuthRequest(view, handler, host, realm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
var cordova = require('cordova'),
|
||||
channel = require('cordova/channel'),
|
||||
urlutil = require('cordova/urlutil');
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
|
||||
var browserWrap,
|
||||
popup,
|
||||
@@ -68,11 +66,12 @@ var IAB = {
|
||||
open: function (win, lose, args) {
|
||||
var strUrl = args[0],
|
||||
target = args[1],
|
||||
features = args[2],
|
||||
url;
|
||||
features = args[2];
|
||||
|
||||
if (target === "_system" || target === "_self" || !target) {
|
||||
if (target === "_self" || !target) {
|
||||
window.location = strUrl;
|
||||
} else if (target === "_system") {
|
||||
modulemapper.getOriginalSymbol(window, 'window.open').call(window, strUrl, "_blank");
|
||||
} else {
|
||||
// "_blank" or anything else
|
||||
if (!browserWrap) {
|
||||
@@ -190,7 +189,9 @@ var IAB = {
|
||||
if (browserWrap && popup) {
|
||||
try {
|
||||
popup.contentWindow.eval(code);
|
||||
hasCallback && win([]);
|
||||
if (hasCallback) {
|
||||
win([]);
|
||||
}
|
||||
} catch(e) {
|
||||
console.error('Error occured while trying to injectScriptCode: ' + JSON.stringify(e));
|
||||
}
|
||||
@@ -200,19 +201,25 @@ var IAB = {
|
||||
injectScriptFile: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented';
|
||||
console.warn(msg);
|
||||
fail && fail(msg);
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
}
|
||||
},
|
||||
|
||||
injectStyleCode: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
|
||||
console.warn(msg);
|
||||
fail && fail(msg);
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
}
|
||||
},
|
||||
|
||||
injectStyleFile: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented';
|
||||
console.warn(msg);
|
||||
fail && fail(msg);
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/WebAPI/Browser
|
||||
|
||||
var cordova = require('cordova'),
|
||||
channel = require('cordova/channel'),
|
||||
modulemapper = require('cordova/modulemapper');
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
|
||||
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'window.open');
|
||||
var browserWrap;
|
||||
@@ -49,9 +47,7 @@ var IABExecs = {
|
||||
var strUrl = args[0],
|
||||
target = args[1],
|
||||
features_string = args[2] || "location=yes", //location=yes is default
|
||||
features = {},
|
||||
url,
|
||||
elem;
|
||||
features = {};
|
||||
|
||||
var features_list = features_string.split(',');
|
||||
features_list.forEach(function(feature) {
|
||||
@@ -61,7 +57,7 @@ var IABExecs = {
|
||||
} else if (tup[1] == 'no') {
|
||||
tup[1] = false;
|
||||
} else {
|
||||
var number = parseInt(tup[1]);
|
||||
var number = parseInt(tup[1]);
|
||||
if (!isNaN(number)) {
|
||||
tup[1] = number;
|
||||
}
|
||||
@@ -115,7 +111,7 @@ var IABExecs = {
|
||||
back.classList.add('inAppBrowserBack');
|
||||
forward.classList.add('inAppBrowserForward');
|
||||
|
||||
function checkForwardBackward() {
|
||||
var checkForwardBackward = function () {
|
||||
var backReq = browserElem.getCanGoBack();
|
||||
backReq.onsuccess = function() {
|
||||
if (this.result) {
|
||||
@@ -123,7 +119,7 @@ var IABExecs = {
|
||||
} else {
|
||||
back.classList.add('disabled');
|
||||
}
|
||||
}
|
||||
};
|
||||
var forwardReq = browserElem.getCanGoForward();
|
||||
forwardReq.onsuccess = function() {
|
||||
if (this.result) {
|
||||
@@ -131,7 +127,7 @@ var IABExecs = {
|
||||
} else {
|
||||
forward.classList.add('disabled');
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
browserElem.addEventListener('mozbrowserloadend', checkForwardBackward);
|
||||
@@ -163,16 +159,16 @@ var IABExecs = {
|
||||
win({
|
||||
type:'loadstart',
|
||||
url : e.detail
|
||||
})
|
||||
});
|
||||
}, false);
|
||||
browserElem.addEventListener('mozbrowserloadend', function(e){
|
||||
win({type:'loadstop'})
|
||||
win({type:'loadstop'});
|
||||
}, false);
|
||||
browserElem.addEventListener('mozbrowsererror', function(e){
|
||||
win({type:'loaderror'})
|
||||
win({type:'loaderror'});
|
||||
}, false);
|
||||
browserElem.addEventListener('mozbrowserclose', function(e){
|
||||
win({type:'exit'})
|
||||
win({type:'exit'});
|
||||
}, false);
|
||||
} else {
|
||||
window.location = strUrl;
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
@class CDVInAppBrowserViewController;
|
||||
|
||||
@interface CDVInAppBrowser : CDVPlugin {
|
||||
BOOL _injectedIframeBridge;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController;
|
||||
|
||||
@@ -214,30 +214,36 @@
|
||||
|
||||
_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
|
||||
|
||||
CDVInAppBrowserNavigationController* nav = [[CDVInAppBrowserNavigationController alloc]
|
||||
__block CDVInAppBrowserNavigationController* nav = [[CDVInAppBrowserNavigationController alloc]
|
||||
initWithRootViewController:self.inAppBrowserViewController];
|
||||
nav.orientationDelegate = self.inAppBrowserViewController;
|
||||
nav.navigationBarHidden = YES;
|
||||
|
||||
__weak CDVInAppBrowser* weakSelf = self;
|
||||
|
||||
// Run later to avoid the "took a long time" log message.
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.inAppBrowserViewController != nil) {
|
||||
[self.viewController presentViewController:nav animated:YES completion:nil];
|
||||
if (weakSelf.inAppBrowserViewController != nil) {
|
||||
[weakSelf.viewController presentViewController:nav animated:YES completion:nil];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
|
||||
{
|
||||
if ([self.commandDelegate URLIsWhitelisted:url]) {
|
||||
NSURLRequest* request = [NSURLRequest requestWithURL:url];
|
||||
NSURLRequest* request = [NSURLRequest requestWithURL:url];
|
||||
|
||||
#ifdef __CORDOVA_4_0_0
|
||||
[self.webViewEngine loadRequest:request];
|
||||
// the webview engine itself will filter for this according to <allow-navigation> policy
|
||||
// in config.xml for cordova-ios-4.0
|
||||
[self.webViewEngine loadRequest:request];
|
||||
#else
|
||||
if ([self.commandDelegate URLIsWhitelisted:url]) {
|
||||
[self.webView loadRequest:request];
|
||||
#endif
|
||||
} else { // this assumes the InAppBrowser can be excepted from the white-list
|
||||
[self openInInAppBrowser:url withOptions:options];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)openInSystem:(NSURL*)url
|
||||
@@ -260,11 +266,8 @@
|
||||
|
||||
- (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper
|
||||
{
|
||||
if (!_injectedIframeBridge) {
|
||||
_injectedIframeBridge = YES;
|
||||
// Create an iframe bridge in the new document to communicate with the CDVInAppBrowserViewController
|
||||
[self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){var e = _cdvIframeBridge = d.createElement('iframe');e.style.display='none';d.body.appendChild(e);})(document)"];
|
||||
}
|
||||
// Ensure an iframe bridge is created to communicate with the CDVInAppBrowserViewController
|
||||
[self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){_cdvIframeBridge=d.getElementById('_cdvIframeBridge');if(!_cdvIframeBridge) {var e = _cdvIframeBridge = d.createElement('iframe');e.id='_cdvIframeBridge'; e.style.display='none';d.body.appendChild(e);}})(document)"];
|
||||
|
||||
if (jsWrapper != nil) {
|
||||
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:@[source] options:0 error:nil];
|
||||
@@ -387,7 +390,14 @@
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:scriptCallbackId];
|
||||
return NO;
|
||||
}
|
||||
} else if ((self.callbackId != nil) && isTopLevelNavigation) {
|
||||
}
|
||||
//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];
|
||||
[self openInSystem:url];
|
||||
return NO;
|
||||
}
|
||||
else if ((self.callbackId != nil) && isTopLevelNavigation) {
|
||||
// Send a loadstart event for each top-level navigation (includes redirects).
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsDictionary:@{@"type":@"loadstart", @"url":[url absoluteString]}];
|
||||
@@ -401,7 +411,6 @@
|
||||
|
||||
- (void)webViewDidStartLoad:(UIWebView*)theWebView
|
||||
{
|
||||
_injectedIframeBridge = NO;
|
||||
}
|
||||
|
||||
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
|
||||
@@ -444,7 +453,9 @@
|
||||
self.inAppBrowserViewController = nil;
|
||||
|
||||
if (IsAtLeastiOSVersion(@"7.0")) {
|
||||
[[UIApplication sharedApplication] setStatusBarStyle:_previousStatusBarStyle];
|
||||
if (_previousStatusBarStyle != -1) {
|
||||
[[UIApplication sharedApplication] setStatusBarStyle:_previousStatusBarStyle];
|
||||
}
|
||||
}
|
||||
|
||||
_previousStatusBarStyle = -1; // this value was reset before reapplying it. caused statusbar to stay black on ios7
|
||||
@@ -477,6 +488,11 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
// Prevent crashes on closing windows
|
||||
-(void)dealloc {
|
||||
self.webView.delegate = nil;
|
||||
}
|
||||
|
||||
- (void)createViews
|
||||
{
|
||||
// We create the views in code for primarily for ease of upgrades and not requiring an external .xib to be included
|
||||
@@ -502,15 +518,15 @@
|
||||
self.webView.scalesPageToFit = NO;
|
||||
self.webView.userInteractionEnabled = YES;
|
||||
|
||||
self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
|
||||
self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
|
||||
self.spinner.alpha = 1.000;
|
||||
self.spinner.autoresizesSubviews = YES;
|
||||
self.spinner.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
|
||||
self.spinner.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin);
|
||||
self.spinner.clearsContextBeforeDrawing = NO;
|
||||
self.spinner.clipsToBounds = NO;
|
||||
self.spinner.contentMode = UIViewContentModeScaleToFill;
|
||||
self.spinner.frame = CGRectMake(454.0, 231.0, 20.0, 20.0);
|
||||
self.spinner.hidden = YES;
|
||||
self.spinner.frame = CGRectMake(CGRectGetMidX(self.webView.frame), CGRectGetMidY(self.webView.frame), 20.0, 20.0);
|
||||
self.spinner.hidden = NO;
|
||||
self.spinner.hidesWhenStopped = YES;
|
||||
self.spinner.multipleTouchEnabled = NO;
|
||||
self.spinner.opaque = NO;
|
||||
@@ -739,6 +755,10 @@
|
||||
return UIStatusBarStyleDefault;
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden {
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)close
|
||||
{
|
||||
[CDVUserAgentUtil releaseLock:&_userAgentLockToken];
|
||||
@@ -748,12 +768,14 @@
|
||||
[self.navigationDelegate browserExit];
|
||||
}
|
||||
|
||||
__weak UIViewController* weakSelf = self;
|
||||
|
||||
// Run later to avoid the "took a long time" log message.
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if ([self respondsToSelector:@selector(presentingViewController)]) {
|
||||
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
|
||||
if ([weakSelf respondsToSelector:@selector(presentingViewController)]) {
|
||||
[[weakSelf presentingViewController] dismissViewControllerAnimated:YES completion:nil];
|
||||
} else {
|
||||
[[self parentViewController] dismissViewControllerAnimated:YES completion:nil];
|
||||
[[weakSelf parentViewController] dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -765,10 +787,11 @@
|
||||
if (_userAgentLockToken != 0) {
|
||||
[self.webView loadRequest:request];
|
||||
} else {
|
||||
__weak CDVInAppBrowserViewController* weakSelf = self;
|
||||
[CDVUserAgentUtil acquireLock:^(NSInteger lockToken) {
|
||||
_userAgentLockToken = lockToken;
|
||||
[CDVUserAgentUtil setUserAgent:_userAgent lockToken:lockToken];
|
||||
[self.webView loadRequest:request];
|
||||
[weakSelf.webView loadRequest:request];
|
||||
}];
|
||||
}
|
||||
}
|
||||
@@ -975,19 +998,38 @@
|
||||
|
||||
@implementation CDVInAppBrowserNavigationController : UINavigationController
|
||||
|
||||
- (void) dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
|
||||
if ( self.presentedViewController) {
|
||||
[super dismissViewControllerAnimated:flag completion:completion];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) viewDidLoad {
|
||||
|
||||
CGRect frame = [UIApplication sharedApplication].statusBarFrame;
|
||||
|
||||
// simplified from: http://stackoverflow.com/a/25669695/219684
|
||||
|
||||
UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:frame];
|
||||
UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:[self invertFrameIfNeeded:frame]];
|
||||
bgToolbar.barStyle = UIBarStyleDefault;
|
||||
[bgToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
|
||||
[self.view addSubview:bgToolbar];
|
||||
|
||||
[super viewDidLoad];
|
||||
}
|
||||
|
||||
- (CGRect) invertFrameIfNeeded:(CGRect)rect {
|
||||
// We need to invert since on iOS 7 frames are always in Portrait context
|
||||
if (!IsAtLeastiOSVersion(@"8.0")) {
|
||||
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
|
||||
CGFloat temp = rect.size.width;
|
||||
rect.size.width = rect.size.height;
|
||||
rect.size.height = temp;
|
||||
}
|
||||
rect.origin = CGPointZero;
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
#pragma mark CDVScreenOrientationDelegate
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* jshint -W061 */
|
||||
/* global oxide */
|
||||
|
||||
oxide.addMessageHandler("EXECUTE", function(msg) {
|
||||
var code = msg.args.code;
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
@@ -19,13 +19,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*jslint sloppy:true */
|
||||
/*global Windows:true, require, document, setTimeout, window, module */
|
||||
|
||||
|
||||
/* jslint sloppy:true */
|
||||
/* global Windows:true, setImmediate */
|
||||
|
||||
var cordova = require('cordova'),
|
||||
channel = require('cordova/channel'),
|
||||
urlutil = require('cordova/urlutil');
|
||||
|
||||
var browserWrap,
|
||||
@@ -35,11 +32,12 @@ var browserWrap,
|
||||
backButton,
|
||||
forwardButton,
|
||||
closeButton,
|
||||
bodyOverflowStyle;
|
||||
bodyOverflowStyle,
|
||||
navigationEventsCallback;
|
||||
|
||||
// x-ms-webview is available starting from Windows 8.1 (platformId is 'windows')
|
||||
// http://msdn.microsoft.com/en-us/library/windows/apps/dn301831.aspx
|
||||
var isWebViewAvailable = cordova.platformId == 'windows';
|
||||
var isWebViewAvailable = cordova.platformId === 'windows';
|
||||
|
||||
function attachNavigationEvents(element, callback) {
|
||||
if (isWebViewAvailable) {
|
||||
@@ -48,19 +46,32 @@ function attachNavigationEvents(element, callback) {
|
||||
});
|
||||
|
||||
element.addEventListener("MSWebViewNavigationCompleted", function (e) {
|
||||
callback({ type: e.isSuccess ? "loadstop" : "loaderror", url: e.uri}, {keepCallback: true});
|
||||
if (e.isSuccess) {
|
||||
callback({ type: "loadstop", url: e.uri }, { keepCallback: true });
|
||||
} else {
|
||||
callback({ type: "loaderror", url: e.uri, code: e.webErrorStatus, message: "Navigation failed with error code " + e.webErrorStatus}, { keepCallback: true });
|
||||
}
|
||||
});
|
||||
|
||||
element.addEventListener("MSWebViewUnviewableContentIdentified", function (e) {
|
||||
// WebView found the content to be not HTML.
|
||||
// http://msdn.microsoft.com/en-us/library/windows/apps/dn609716.aspx
|
||||
callback({ type: "loaderror", url: e.uri}, {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) {
|
||||
if (navigationButtonsDiv) {
|
||||
backButton.disabled = !popup.canGoBack;
|
||||
forwardButton.disabled = !popup.canGoForward;
|
||||
if (navigationButtonsDiv && popup) {
|
||||
if (popup.canGoBack) {
|
||||
backButton.removeAttribute("disabled");
|
||||
} else {
|
||||
backButton.setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
if (popup.canGoForward) {
|
||||
forwardButton.removeAttribute("disabled");
|
||||
} else {
|
||||
forwardButton.setAttribute("disabled", "true");
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -83,227 +94,232 @@ function attachNavigationEvents(element, callback) {
|
||||
|
||||
var IAB = {
|
||||
close: function (win, lose) {
|
||||
if (browserWrap) {
|
||||
if (win) win({ type: "exit" });
|
||||
setImmediate(function () {
|
||||
if (browserWrap) {
|
||||
if (navigationEventsCallback) {
|
||||
navigationEventsCallback({ type: "exit" });
|
||||
}
|
||||
|
||||
browserWrap.parentNode.removeChild(browserWrap);
|
||||
// Reset body overflow style to initial value
|
||||
document.body.style.msOverflowStyle = bodyOverflowStyle;
|
||||
browserWrap = null;
|
||||
popup = null;
|
||||
}
|
||||
browserWrap.parentNode.removeChild(browserWrap);
|
||||
// Reset body overflow style to initial value
|
||||
document.body.style.msOverflowStyle = bodyOverflowStyle;
|
||||
browserWrap = null;
|
||||
popup = null;
|
||||
}
|
||||
});
|
||||
},
|
||||
show: function (win, lose) {
|
||||
if (browserWrap) {
|
||||
browserWrap.style.display = "block";
|
||||
}
|
||||
setImmediate(function () {
|
||||
if (browserWrap) {
|
||||
browserWrap.style.display = "block";
|
||||
}
|
||||
});
|
||||
},
|
||||
open: function (win, lose, args) {
|
||||
var strUrl = args[0],
|
||||
target = args[1],
|
||||
features = args[2],
|
||||
url;
|
||||
// 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;
|
||||
|
||||
if (target === "_system") {
|
||||
url = new Windows.Foundation.Uri(strUrl);
|
||||
Windows.System.Launcher.launchUriAsync(url);
|
||||
} else if (target === "_self" || !target) {
|
||||
window.location = strUrl;
|
||||
} else {
|
||||
// "_blank" or anything else
|
||||
if (!browserWrap) {
|
||||
var browserWrapStyle = document.createElement('link');
|
||||
browserWrapStyle.rel = "stylesheet";
|
||||
browserWrapStyle.type = "text/css";
|
||||
browserWrapStyle.href = urlutil.makeAbsolute("/www/css/inappbrowser.css");
|
||||
navigationEventsCallback = win;
|
||||
|
||||
document.head.appendChild(browserWrapStyle);
|
||||
|
||||
browserWrap = document.createElement("div");
|
||||
browserWrap.className = "inAppBrowserWrap";
|
||||
|
||||
if (features.indexOf("fullscreen=yes") > -1) {
|
||||
browserWrap.classList.add("inAppBrowserWrapFullscreen");
|
||||
}
|
||||
|
||||
// Save body overflow style to be able to reset it back later
|
||||
bodyOverflowStyle = document.body.style.msOverflowStyle;
|
||||
|
||||
browserWrap.onclick = function () {
|
||||
setTimeout(function () {
|
||||
IAB.close(win);
|
||||
}, 0);
|
||||
};
|
||||
|
||||
document.body.appendChild(browserWrap);
|
||||
// Hide scrollbars for the whole body while inappbrowser's window is open
|
||||
document.body.style.msOverflowStyle = "none";
|
||||
}
|
||||
|
||||
if (features.indexOf("hidden=yes") !== -1) {
|
||||
browserWrap.style.display = "none";
|
||||
}
|
||||
|
||||
popup = document.createElement(isWebViewAvailable ? "x-ms-webview" : "iframe");
|
||||
if (popup instanceof HTMLIFrameElement) {
|
||||
// For iframe we need to override bacground color of parent element here
|
||||
// otherwise pages without background color set will have transparent background
|
||||
popup.style.backgroundColor = "white";
|
||||
}
|
||||
popup.style.borderWidth = "0px";
|
||||
popup.style.width = "100%";
|
||||
|
||||
browserWrap.appendChild(popup);
|
||||
|
||||
if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) {
|
||||
popup.style.height = "calc(100% - 60px)";
|
||||
|
||||
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.onclick = function (e) {
|
||||
e.cancelBubble = true;
|
||||
};
|
||||
|
||||
|
||||
backButton = document.createElement("button");
|
||||
backButton.style.width = "40px";
|
||||
backButton.style.height = "40px";
|
||||
backButton.style.borderRadius = "40px";
|
||||
|
||||
backButton.innerText = "<-";
|
||||
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.innerText = "->";
|
||||
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.innerText = "x";
|
||||
closeButton.addEventListener("click", function (e) {
|
||||
setTimeout(function () {
|
||||
IAB.close(win);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
if (!isWebViewAvailable) {
|
||||
// iframe navigation is not yet supported
|
||||
backButton.disabled = true;
|
||||
forwardButton.disabled = true;
|
||||
}
|
||||
|
||||
navigationButtonsDivInner.appendChild(backButton);
|
||||
navigationButtonsDivInner.appendChild(forwardButton);
|
||||
navigationButtonsDivInner.appendChild(closeButton);
|
||||
navigationButtonsDiv.appendChild(navigationButtonsDivInner);
|
||||
|
||||
browserWrap.appendChild(navigationButtonsDiv);
|
||||
if (target === "_system") {
|
||||
url = new Windows.Foundation.Uri(strUrl);
|
||||
Windows.System.Launcher.launchUriAsync(url);
|
||||
} else if (target === "_self" || !target) {
|
||||
window.location = strUrl;
|
||||
} else {
|
||||
popup.style.height = "100%";
|
||||
}
|
||||
// "_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");
|
||||
|
||||
// start listening for navigation events
|
||||
attachNavigationEvents(popup, win);
|
||||
document.head.appendChild(browserWrapStyle);
|
||||
|
||||
if (isWebViewAvailable) {
|
||||
strUrl = strUrl.replace("ms-appx://", "ms-appx-web://");
|
||||
browserWrap = document.createElement("div");
|
||||
browserWrap.className = "inAppBrowserWrap";
|
||||
|
||||
if (features.indexOf("fullscreen=yes") > -1) {
|
||||
browserWrap.classList.add("inAppBrowserWrapFullscreen");
|
||||
}
|
||||
|
||||
// Save body overflow style to be able to reset it back later
|
||||
bodyOverflowStyle = document.body.style.msOverflowStyle;
|
||||
|
||||
browserWrap.onclick = function () {
|
||||
setTimeout(function () {
|
||||
IAB.close(navigationEventsCallback);
|
||||
}, 0);
|
||||
};
|
||||
|
||||
document.body.appendChild(browserWrap);
|
||||
// Hide scrollbars for the whole body while inappbrowser's window is open
|
||||
document.body.style.msOverflowStyle = "none";
|
||||
}
|
||||
|
||||
if (features.indexOf("hidden=yes") !== -1) {
|
||||
browserWrap.style.display = "none";
|
||||
}
|
||||
|
||||
popup = document.createElement(isWebViewAvailable ? "x-ms-webview" : "iframe");
|
||||
if (popup instanceof HTMLIFrameElement) {
|
||||
// For iframe we need to override bacground color of parent element here
|
||||
// otherwise pages without background color set will have transparent background
|
||||
popup.style.backgroundColor = "white";
|
||||
}
|
||||
popup.style.borderWidth = "0px";
|
||||
popup.style.width = "100%";
|
||||
|
||||
browserWrap.appendChild(popup);
|
||||
|
||||
if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) {
|
||||
popup.style.height = "calc(100% - 70px)";
|
||||
|
||||
navigationButtonsDiv = document.createElement("div");
|
||||
navigationButtonsDiv.className = "inappbrowser-app-bar";
|
||||
navigationButtonsDiv.onclick = function (e) {
|
||||
e.cancelBubble = true;
|
||||
};
|
||||
|
||||
navigationButtonsDivInner = document.createElement("div");
|
||||
navigationButtonsDivInner.className = "inappbrowser-app-bar-inner";
|
||||
navigationButtonsDivInner.onclick = function (e) {
|
||||
e.cancelBubble = true;
|
||||
};
|
||||
|
||||
backButton = document.createElement("div");
|
||||
backButton.innerText = "back";
|
||||
backButton.className = "app-bar-action action-back";
|
||||
backButton.addEventListener("click", function (e) {
|
||||
if (popup.canGoBack)
|
||||
popup.goBack();
|
||||
});
|
||||
|
||||
forwardButton = document.createElement("div");
|
||||
forwardButton.innerText = "forward";
|
||||
forwardButton.className = "app-bar-action action-forward";
|
||||
forwardButton.addEventListener("click", function (e) {
|
||||
if (popup.canGoForward)
|
||||
popup.goForward();
|
||||
});
|
||||
|
||||
closeButton = document.createElement("div");
|
||||
closeButton.innerText = "close";
|
||||
closeButton.className = "app-bar-action action-close";
|
||||
closeButton.addEventListener("click", function (e) {
|
||||
setTimeout(function () {
|
||||
IAB.close(navigationEventsCallback);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
if (!isWebViewAvailable) {
|
||||
// iframe navigation is not yet supported
|
||||
backButton.setAttribute("disabled", "true");
|
||||
forwardButton.setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
navigationButtonsDivInner.appendChild(backButton);
|
||||
navigationButtonsDivInner.appendChild(forwardButton);
|
||||
navigationButtonsDivInner.appendChild(closeButton);
|
||||
navigationButtonsDiv.appendChild(navigationButtonsDivInner);
|
||||
|
||||
browserWrap.appendChild(navigationButtonsDiv);
|
||||
} else {
|
||||
popup.style.height = "100%";
|
||||
}
|
||||
|
||||
// start listening for navigation events
|
||||
attachNavigationEvents(popup, navigationEventsCallback);
|
||||
|
||||
if (isWebViewAvailable) {
|
||||
strUrl = strUrl.replace("ms-appx://", "ms-appx-web://");
|
||||
}
|
||||
popup.src = strUrl;
|
||||
}
|
||||
popup.src = strUrl;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
injectScriptCode: function (win, fail, args) {
|
||||
var code = args[0],
|
||||
hasCallback = args[1];
|
||||
setImmediate(function () {
|
||||
var code = args[0],
|
||||
hasCallback = args[1];
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
var op = popup.invokeScriptAsync("eval", code);
|
||||
op.oncomplete = function (e) {
|
||||
var result = [e.target.result];
|
||||
hasCallback && win(result);
|
||||
};
|
||||
op.onerror = function () { };
|
||||
op.start();
|
||||
}
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
var op = popup.invokeScriptAsync("eval", code);
|
||||
op.oncomplete = function (e) {
|
||||
if (hasCallback) {
|
||||
// return null if event target is unavailable by some reason
|
||||
var result = (e && e.target) ? [e.target.result] : [null];
|
||||
win(result);
|
||||
}
|
||||
};
|
||||
op.onerror = function () { };
|
||||
op.start();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
injectScriptFile: function (win, fail, args) {
|
||||
var filePath = args[0],
|
||||
hasCallback = args[1];
|
||||
setImmediate(function () {
|
||||
var filePath = args[0],
|
||||
hasCallback = args[1];
|
||||
|
||||
if (!!filePath) {
|
||||
filePath = urlutil.makeAbsolute(filePath);
|
||||
}
|
||||
if (!!filePath) {
|
||||
filePath = urlutil.makeAbsolute(filePath);
|
||||
}
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
var uri = new Windows.Foundation.Uri(filePath);
|
||||
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 result = [e.target.result];
|
||||
hasCallback && win(result);
|
||||
};
|
||||
op.onerror = function () { };
|
||||
op.start();
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
var uri = new Windows.Foundation.Uri(filePath);
|
||||
Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).done(function (file) {
|
||||
Windows.Storage.FileIO.readTextAsync(file).done(function (code) {
|
||||
var op = popup.invokeScriptAsync("eval", code);
|
||||
op.oncomplete = function(e) {
|
||||
if (hasCallback) {
|
||||
var result = [e.target.result];
|
||||
win(result);
|
||||
}
|
||||
};
|
||||
op.onerror = function () { };
|
||||
op.start();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
injectStyleCode: function (win, fail, args) {
|
||||
var code = args[0],
|
||||
hasCallback = args[1];
|
||||
setImmediate(function () {
|
||||
var code = args[0],
|
||||
hasCallback = args[1];
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
injectCSS(popup, code, hasCallback && win);
|
||||
}
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
injectCSS(popup, code, hasCallback && win);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
injectStyleFile: function (win, fail, args) {
|
||||
var filePath = args[0],
|
||||
hasCallback = args[1];
|
||||
setImmediate(function () {
|
||||
var filePath = args[0],
|
||||
hasCallback = args[1];
|
||||
|
||||
filePath = filePath && urlutil.makeAbsolute(filePath);
|
||||
filePath = filePath && urlutil.makeAbsolute(filePath);
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
var uri = new Windows.Foundation.Uri(filePath);
|
||||
Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).then(function (file) {
|
||||
return Windows.Storage.FileIO.readTextAsync(file);
|
||||
}).done(function (code) {
|
||||
injectCSS(popup, code, hasCallback && win);
|
||||
}, function () {
|
||||
// no-op, just catch an error
|
||||
});
|
||||
}
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
var uri = new Windows.Foundation.Uri(filePath);
|
||||
Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).then(function (file) {
|
||||
return Windows.Storage.FileIO.readTextAsync(file);
|
||||
}).done(function (code) {
|
||||
injectCSS(popup, code, hasCallback && win);
|
||||
}, function () {
|
||||
// no-op, just catch an error
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -315,7 +331,9 @@ function injectCSS (webView, cssCode, callback) {
|
||||
|
||||
var op = webView.invokeScriptAsync("eval", evalWrapper);
|
||||
op.oncomplete = function() {
|
||||
callback && callback([]);
|
||||
if (callback) {
|
||||
callback([]);
|
||||
}
|
||||
};
|
||||
op.onerror = function () { };
|
||||
op.start();
|
||||
|
||||
@@ -20,10 +20,12 @@
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-inappbrowser-tests"
|
||||
version="1.0.2-dev">
|
||||
version="1.4.0">
|
||||
<name>Cordova InAppBrowser Plugin Tests</name>
|
||||
<license>Apache 2.0</license>
|
||||
|
||||
<dependency id="cordova-plugin-dialogs" />
|
||||
|
||||
<js-module src="tests.js" name="tests">
|
||||
</js-module>
|
||||
|
||||
|
||||
@@ -16,5 +16,5 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
var d = document.getElementById("header")
|
||||
var d = document.getElementById("header");
|
||||
d.innerHTML = "Script file successfully injected";
|
||||
|
||||
@@ -38,5 +38,8 @@
|
||||
<button onclick="document.getElementById('player').play()"> play </button>
|
||||
<button onclick="document.getElementById('player').pause()"> pause </button>
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById('player').play();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
132
tests/tests.js
132
tests/tests.js
@@ -19,11 +19,118 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* jshint jasmine: true */
|
||||
/* global MSApp */
|
||||
|
||||
var cordova = require('cordova');
|
||||
var isWindows = cordova.platformId == 'windows';
|
||||
|
||||
window.alert = window.alert || navigator.notification.alert;
|
||||
|
||||
exports.defineAutoTests = function () {
|
||||
|
||||
describe('cordova.InAppBrowser', function () {
|
||||
|
||||
it("inappbrowser.spec.1 should exist", function () {
|
||||
expect(cordova.InAppBrowser).toBeDefined();
|
||||
});
|
||||
|
||||
it("inappbrowser.spec.2 should contain open function", function () {
|
||||
expect(cordova.InAppBrowser.open).toBeDefined();
|
||||
expect(cordova.InAppBrowser.open).toEqual(jasmine.any(Function));
|
||||
});
|
||||
});
|
||||
|
||||
describe('open method', function () {
|
||||
|
||||
var iabInstance;
|
||||
var originalTimeout;
|
||||
var url = 'https://dist.apache.org/repos/dist/dev/cordova/';
|
||||
var badUrl = 'http://bad-uri/';
|
||||
|
||||
beforeEach(function () {
|
||||
// increase timeout to ensure test url could be loaded within test time
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
|
||||
iabInstance = null;
|
||||
});
|
||||
|
||||
afterEach(function (done) {
|
||||
// restore original timeout
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
|
||||
if (iabInstance !== null && iabInstance.close) {
|
||||
iabInstance.close();
|
||||
}
|
||||
iabInstance = null;
|
||||
// add some extra time so that iab dialog is closed
|
||||
setTimeout(done, 2000);
|
||||
});
|
||||
|
||||
function verifyEvent(evt, type) {
|
||||
expect(evt).toBeDefined();
|
||||
expect(evt.type).toEqual(type);
|
||||
if (type !== 'exit') { // `exit` event does not have url field
|
||||
expect(evt.url).toEqual(url);
|
||||
}
|
||||
}
|
||||
|
||||
function verifyLoadErrorEvent(evt) {
|
||||
expect(evt).toBeDefined();
|
||||
expect(evt.type).toEqual('loaderror');
|
||||
expect(evt.url).toEqual(badUrl);
|
||||
expect(evt.code).toEqual(jasmine.any(Number));
|
||||
expect(evt.message).toEqual(jasmine.any(String));
|
||||
}
|
||||
|
||||
it("inappbrowser.spec.3 should retun InAppBrowser instance with required methods", function () {
|
||||
iabInstance = cordova.InAppBrowser.open(url, '_blank');
|
||||
|
||||
expect(iabInstance).toBeDefined();
|
||||
|
||||
expect(iabInstance.addEventListener).toEqual(jasmine.any(Function));
|
||||
expect(iabInstance.removeEventListener).toEqual(jasmine.any(Function));
|
||||
expect(iabInstance.close).toEqual(jasmine.any(Function));
|
||||
expect(iabInstance.show).toEqual(jasmine.any(Function));
|
||||
expect(iabInstance.executeScript).toEqual(jasmine.any(Function));
|
||||
expect(iabInstance.insertCSS).toEqual(jasmine.any(Function));
|
||||
});
|
||||
|
||||
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');
|
||||
});
|
||||
|
||||
iabInstance = cordova.InAppBrowser.open(url, '_blank');
|
||||
iabInstance.addEventListener('loadstart', onLoadStart);
|
||||
iabInstance.addEventListener('loadstop', function (evt) {
|
||||
verifyEvent(evt, 'loadstop');
|
||||
expect(onLoadStart).toHaveBeenCalled();
|
||||
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');
|
||||
done();
|
||||
});
|
||||
iabInstance.close();
|
||||
iabInstance = null;
|
||||
});
|
||||
|
||||
it("inappbrowser.spec.6 should support loaderror event", function (done) {
|
||||
iabInstance = cordova.InAppBrowser.open(badUrl, '_blank');
|
||||
iabInstance.addEventListener('loaderror', function (evt) {
|
||||
verifyLoadErrorEvent(evt);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
|
||||
function doOpen(url, target, params, numExpectedRedirects, useWindowOpen) {
|
||||
@@ -79,13 +186,13 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
if (e.url != lastLoadStartURL) {
|
||||
alert('Unexpected: ' + e.type + ' event.url != loadstart\'s event.url');
|
||||
}
|
||||
if (numExpectedRedirects === 0 && counts['loadstart'] !== 1) {
|
||||
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 + ')');
|
||||
}
|
||||
} else if (numExpectedRedirects > 0 && counts['loadstart'] < (numExpectedRedirects + 1)) {
|
||||
alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts['loadstart']);
|
||||
} else if (numExpectedRedirects > 0 && counts.loadstart < (numExpectedRedirects + 1)) {
|
||||
alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts.loadstart);
|
||||
}
|
||||
wasReset = true;
|
||||
numExpectedRedirects = 0;
|
||||
@@ -93,7 +200,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
}
|
||||
// Verify that loadend / loaderror was called.
|
||||
if (e.type == 'exit') {
|
||||
var numStopEvents = counts['loadstop'] + counts['loaderror'];
|
||||
var numStopEvents = counts.loadstop + counts.loaderror;
|
||||
if (numStopEvents === 0 && !wasReset) {
|
||||
alert('Unexpected: browser closed without a loadstop or loaderror.');
|
||||
} else if (numStopEvents > 1) {
|
||||
@@ -319,7 +426,11 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
|
||||
var video_tag_tests = '<h1>Video tag</h1>' +
|
||||
'<div id="openRemoteVideo"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with an embedded video that works after clicking the "play" button.';
|
||||
'Expected result: open successfully in InAppBrowser with an embedded video plays automatically on iOS and Android.' +
|
||||
'<div id="openRemoteNeedUserNoVideo"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with an embedded video plays automatically on iOS and Android.' +
|
||||
'<div id="openRemoteNeedUserYesVideo"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with an embedded video does not play automatically on iOS and Android but rather works after clicking the "play" button.';
|
||||
|
||||
var local_with_anchor_tag_tests = '<h1>Local with anchor tag</h1>' +
|
||||
'<div id="openAnchor1"></div>' +
|
||||
@@ -507,6 +618,12 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
createActionButton('Remote Video', function () {
|
||||
doOpen(videohtml, '_blank');
|
||||
}, 'openRemoteVideo');
|
||||
createActionButton('Remote Need User No Video', function () {
|
||||
doOpen(videohtml, '_blank', 'mediaPlaybackRequiresUserAction=no');
|
||||
}, 'openRemoteNeedUserNoVideo');
|
||||
createActionButton('Remote Need User Yes Video', function () {
|
||||
doOpen(videohtml, '_blank', 'mediaPlaybackRequiresUserAction=yes');
|
||||
}, 'openRemoteNeedUserYesVideo');
|
||||
|
||||
//Local With Anchor Tag
|
||||
createActionButton('Anchor1', function () {
|
||||
@@ -516,4 +633,3 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
doOpen(localhtml + '#anchor2', '_blank');
|
||||
}, 'openAnchor2');
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
@@ -20,7 +20,6 @@
|
||||
.inAppBrowserWrap {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
@@ -28,15 +27,88 @@
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: calc(100% - 80px);
|
||||
height: calc(100% - 80px);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 9999999;
|
||||
box-sizing: border-box;
|
||||
border: 40px solid #bfbfbf;
|
||||
border: 40px solid rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.inAppBrowserWrapFullscreen {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.inappbrowser-app-bar {
|
||||
height: 70px;
|
||||
background-color: #404040;
|
||||
z-index: 9999999;
|
||||
}
|
||||
|
||||
.inappbrowser-app-bar-inner {
|
||||
padding-top: 10px;
|
||||
height: 60px;
|
||||
width: 155px;
|
||||
margin: 0 auto;
|
||||
background-color: #404040;
|
||||
z-index: 9999999;
|
||||
}
|
||||
|
||||
.app-bar-action {
|
||||
width: auto;
|
||||
height: 40px;
|
||||
margin-left: 20px;
|
||||
font-family: "Segoe UI Symbol";
|
||||
float: left;
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
text-transform: lowercase;
|
||||
text-align: center;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.app-bar-action[disabled] {
|
||||
color: gray;
|
||||
/*disable click*/
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.app-bar-action::before {
|
||||
font-size: 28px;
|
||||
display: block;
|
||||
height: 36px;
|
||||
}
|
||||
|
||||
/* Back */
|
||||
.action-back {
|
||||
margin-left: 0px;
|
||||
}
|
||||
|
||||
.action-back::before {
|
||||
content: "\E0BA";
|
||||
}
|
||||
|
||||
.action-back:not([disabled]):hover::before {
|
||||
content: "\E0B3";
|
||||
}
|
||||
|
||||
/* Forward */
|
||||
.action-forward::before {
|
||||
content: "\E0AC";
|
||||
}
|
||||
|
||||
.action-forward:not([disabled]):hover::before {
|
||||
content: "\E0AF";
|
||||
}
|
||||
|
||||
/* Close */
|
||||
.action-close::before {
|
||||
content: "\E0C7";
|
||||
/* close icon is larger so we re-size it to fit other icons */
|
||||
font-size: 20px;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.action-close:not([disabled]):hover::before {
|
||||
content: "\E0CA";
|
||||
}
|
||||
|
||||
@@ -19,86 +19,93 @@
|
||||
*
|
||||
*/
|
||||
|
||||
var exec = require('cordova/exec');
|
||||
var channel = require('cordova/channel');
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
var urlutil = require('cordova/urlutil');
|
||||
|
||||
function InAppBrowser() {
|
||||
this.channels = {
|
||||
'loadstart': channel.create('loadstart'),
|
||||
'loadstop' : channel.create('loadstop'),
|
||||
'loaderror' : channel.create('loaderror'),
|
||||
'exit' : channel.create('exit')
|
||||
};
|
||||
}
|
||||
|
||||
InAppBrowser.prototype = {
|
||||
_eventHandler: function (event) {
|
||||
if (event && (event.type in this.channels)) {
|
||||
this.channels[event.type].fire(event);
|
||||
}
|
||||
},
|
||||
close: function (eventname) {
|
||||
exec(null, null, "InAppBrowser", "close", []);
|
||||
},
|
||||
show: function (eventname) {
|
||||
exec(null, null, "InAppBrowser", "show", []);
|
||||
},
|
||||
addEventListener: function (eventname,f) {
|
||||
if (eventname in this.channels) {
|
||||
this.channels[eventname].subscribe(f);
|
||||
}
|
||||
},
|
||||
removeEventListener: function(eventname, f) {
|
||||
if (eventname in this.channels) {
|
||||
this.channels[eventname].unsubscribe(f);
|
||||
}
|
||||
},
|
||||
|
||||
executeScript: function(injectDetails, cb) {
|
||||
if (injectDetails.code) {
|
||||
exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]);
|
||||
} else if (injectDetails.file) {
|
||||
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) {
|
||||
if (injectDetails.code) {
|
||||
exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]);
|
||||
} else if (injectDetails.file) {
|
||||
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) {
|
||||
// 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');
|
||||
return origOpenFunc.apply(window, arguments);
|
||||
(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
|
||||
return;
|
||||
}
|
||||
|
||||
strUrl = urlutil.makeAbsolute(strUrl);
|
||||
var iab = new InAppBrowser();
|
||||
var exec = require('cordova/exec');
|
||||
var channel = require('cordova/channel');
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
var urlutil = require('cordova/urlutil');
|
||||
|
||||
callbacks = callbacks || {};
|
||||
for (var callbackName in callbacks) {
|
||||
iab.addEventListener(callbackName, callbacks[callbackName]);
|
||||
function InAppBrowser() {
|
||||
this.channels = {
|
||||
'loadstart': channel.create('loadstart'),
|
||||
'loadstop' : channel.create('loadstop'),
|
||||
'loaderror' : channel.create('loaderror'),
|
||||
'exit' : channel.create('exit')
|
||||
};
|
||||
}
|
||||
|
||||
var cb = function(eventname) {
|
||||
iab._eventHandler(eventname);
|
||||
InAppBrowser.prototype = {
|
||||
_eventHandler: function (event) {
|
||||
if (event && (event.type in this.channels)) {
|
||||
this.channels[event.type].fire(event);
|
||||
}
|
||||
},
|
||||
close: function (eventname) {
|
||||
exec(null, null, "InAppBrowser", "close", []);
|
||||
},
|
||||
show: function (eventname) {
|
||||
exec(null, null, "InAppBrowser", "show", []);
|
||||
},
|
||||
addEventListener: function (eventname,f) {
|
||||
if (eventname in this.channels) {
|
||||
this.channels[eventname].subscribe(f);
|
||||
}
|
||||
},
|
||||
removeEventListener: function(eventname, f) {
|
||||
if (eventname in this.channels) {
|
||||
this.channels[eventname].unsubscribe(f);
|
||||
}
|
||||
},
|
||||
|
||||
executeScript: function(injectDetails, cb) {
|
||||
if (injectDetails.code) {
|
||||
exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]);
|
||||
} else if (injectDetails.file) {
|
||||
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) {
|
||||
if (injectDetails.code) {
|
||||
exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]);
|
||||
} else if (injectDetails.file) {
|
||||
exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]);
|
||||
} else {
|
||||
throw new Error('insertCSS requires exactly one of code or file to be specified');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
strWindowFeatures = strWindowFeatures || "";
|
||||
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');
|
||||
return origOpenFunc.apply(window, arguments);
|
||||
}
|
||||
|
||||
exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
|
||||
return iab;
|
||||
};
|
||||
strUrl = urlutil.makeAbsolute(strUrl);
|
||||
var iab = new InAppBrowser();
|
||||
|
||||
callbacks = callbacks || {};
|
||||
for (var callbackName in callbacks) {
|
||||
iab.addEventListener(callbackName, callbacks[callbackName]);
|
||||
}
|
||||
|
||||
var cb = function(eventname) {
|
||||
iab._eventHandler(eventname);
|
||||
};
|
||||
|
||||
strWindowFeatures = strWindowFeatures || "";
|
||||
|
||||
exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
|
||||
return iab;
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -17,16 +17,11 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
/*jslint sloppy:true */
|
||||
/*global Windows:true, require, document, setTimeout, window, module */
|
||||
|
||||
|
||||
|
||||
var cordova = require('cordova'),
|
||||
channel = require('cordova/channel');
|
||||
|
||||
var browserWrap;
|
||||
|
||||
var IAB = {
|
||||
@@ -39,14 +34,13 @@ var IAB = {
|
||||
},
|
||||
show: function (win, lose) {
|
||||
/* empty block, ran out of bacon?
|
||||
if (browserWrap) {
|
||||
if (browserWrap) {
|
||||
|
||||
}*/
|
||||
}*/
|
||||
},
|
||||
open: function (win, lose, args) {
|
||||
var strUrl = args[0],
|
||||
target = args[1],
|
||||
features = args[2],
|
||||
url,
|
||||
elem;
|
||||
|
||||
@@ -62,6 +56,7 @@ var IAB = {
|
||||
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 () {
|
||||
@@ -71,20 +66,38 @@ var IAB = {
|
||||
|
||||
document.body.appendChild(browserWrap);
|
||||
}
|
||||
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.src = strUrl;
|
||||
|
||||
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 () {
|
||||
if (browserWrap && elem) {
|
||||
elem.style.width = (window.innerWidth - 80) + "px";
|
||||
elem.style.height = (window.innerHeight - 80) + "px";
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener("resize", function () {
|
||||
if (browserWrap && elem) {
|
||||
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.src = strUrl;
|
||||
|
||||
|
||||
window.addEventListener("resize", function () {
|
||||
if (browserWrap && elem) {
|
||||
elem.style.width = (window.innerWidth - 80) + "px";
|
||||
elem.style.height = (window.innerHeight - 80) + "px";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
browserWrap.appendChild(elem);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user