@ionic-native/in-app-browser
Version:
Ionic Native - Native plugins for ionic apps
98 lines (93 loc) • 5.24 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var tslib = require('tslib');
var core = require('@angular/core');
var core$1 = require('@ionic-native/core');
var rxjs = require('rxjs');
var InAppBrowserObject = /** @class */ (function () {
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param {string} url The URL to load.
* @param {string} [target="self"] The target in which to load the URL, an optional parameter that defaults to _self.
* _self: Opens in the WebView if the URL is in the white list, otherwise it opens in the InAppBrowser.
* _blank: Opens in the InAppBrowser.
* _system: Opens in the system's web browser.
* @param {string | InAppBrowserOptions} [options] Options for the InAppBrowser. Optional, defaulting to: location=yes.
* The options string must not contain any blank space, and each feature's
* name/value pairs must be separated by a comma. Feature names are case insensitive.
*/
function InAppBrowserObject(url, target, options) {
try {
if (options && typeof options !== 'string') {
options = Object.keys(options)
.map(function (key) { return key + "=" + options[key]; })
.join(',');
}
this._objectInstance = cordova.InAppBrowser.open(url, target, options);
}
catch (e) {
if (typeof window !== 'undefined') {
window.open(url, target);
}
console.warn('Native: InAppBrowser is not installed or you are running on a browser. Falling back to window.open.');
}
}
InAppBrowserObject.prototype._loadAfterBeforeload = function (strUrl) { return core$1.cordovaInstance(this, "_loadAfterBeforeload", { "sync": true }, arguments); };
InAppBrowserObject.prototype.show = function () { return core$1.cordovaInstance(this, "show", { "sync": true }, arguments); };
InAppBrowserObject.prototype.close = function () { return core$1.cordovaInstance(this, "close", { "sync": true }, arguments); };
InAppBrowserObject.prototype.hide = function () { return core$1.cordovaInstance(this, "hide", { "sync": true }, arguments); };
InAppBrowserObject.prototype.executeScript = function (script) { return core$1.cordovaInstance(this, "executeScript", {}, arguments); };
InAppBrowserObject.prototype.insertCSS = function (css) { return core$1.cordovaInstance(this, "insertCSS", {}, arguments); };
InAppBrowserObject.prototype.on = function (event) {
var _this = this;
return (function () {
if (core$1.instanceAvailability(_this) === true) {
return new rxjs.Observable(function (observer) {
_this._objectInstance.addEventListener(event, observer.next.bind(observer));
return function () { return _this._objectInstance.removeEventListener(event, observer.next.bind(observer)); };
});
}
})();
};
InAppBrowserObject.prototype.on = function (event) {
var _this = this;
return (function () {
if (core$1.instanceAvailability(_this) === true) {
return new rxjs.Observable(function (observer) {
_this._objectInstance.addEventListener(event, observer.next.bind(observer));
return function () { return _this._objectInstance.removeEventListener(event, observer.next.bind(observer)); };
});
}
})();
};
return InAppBrowserObject;
}());
var InAppBrowser = /** @class */ (function (_super) {
tslib.__extends(InAppBrowser, _super);
function InAppBrowser() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url {string} The URL to load.
* @param target {string} The target in which to load the URL, an optional parameter that defaults to _self.
* @param options {string} Options for the InAppBrowser. Optional, defaulting to: location=yes.
* The options string must not contain any blank space, and each feature's
* name/value pairs must be separated by a comma. Feature names are case insensitive.
* @returns {InAppBrowserObject}
*/
InAppBrowser.prototype.create = function (url, target, options) {
return new InAppBrowserObject(url, target, options);
};
InAppBrowser.pluginName = "InAppBrowser";
InAppBrowser.plugin = "cordova-plugin-inappbrowser";
InAppBrowser.pluginRef = "cordova.InAppBrowser";
InAppBrowser.repo = "https://github.com/apache/cordova-plugin-inappbrowser";
InAppBrowser.platforms = ["AmazonFire OS", "Android", "Browser", "iOS", "macOS", "Windows"];
InAppBrowser.decorators = [
{ type: core.Injectable }
];
return InAppBrowser;
}(core$1.IonicNativePlugin));
exports.InAppBrowser = InAppBrowser;
exports.InAppBrowserObject = InAppBrowserObject;