mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-04-13 00:00:10 +08:00
refactor(): applied new lint rules
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CordovaInstance, InstanceCheck, IonicNativePlugin, Plugin } from '@ionic-native/core';
|
||||
import {
|
||||
CordovaInstance,
|
||||
InstanceCheck,
|
||||
IonicNativePlugin,
|
||||
Plugin
|
||||
} from '@ionic-native/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observer } from 'rxjs/Observer';
|
||||
|
||||
declare const cordova: Cordova & { InAppBrowser: any; };
|
||||
declare const cordova: Cordova & { InAppBrowser: any };
|
||||
|
||||
export interface InAppBrowserOptions {
|
||||
/** Set to yes or no to turn the InAppBrowser's location bar on or off. */
|
||||
location?: 'yes' | 'no';
|
||||
/** Set to yes to create the browser and load the page, but not show it. The loadstop event fires when loading is complete.
|
||||
/*Set to yes to create the browser and load the page, but not show it. The loadstop event fires when loading is complete.
|
||||
* Omit or set to no (default) to have the browser open and load normally. */
|
||||
hidden?: 'yes' | 'no';
|
||||
/** Set to yes to have the browser's cookie cache cleared before the new window is opened. */
|
||||
@@ -17,7 +22,7 @@ export interface InAppBrowserOptions {
|
||||
clearsessioncache?: 'yes';
|
||||
/** (Android Only) set to yes to show Android browser's zoom controls, set to no to hide them. Default value is yes. */
|
||||
zoom?: 'yes' | 'no';
|
||||
/** Set to yes to use the hardware back button to navigate backwards through the InAppBrowser's history.
|
||||
/*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. */
|
||||
hardwareback?: 'yes' | 'no';
|
||||
/** Set to yes to prevent HTML5 audio or video from autoplaying (defaults to no). */
|
||||
@@ -36,8 +41,10 @@ export interface InAppBrowserOptions {
|
||||
toolbar?: 'yes' | 'no';
|
||||
/** (iOS Only) Set to yes or no to prevent viewport scaling through a meta tag (defaults to no). */
|
||||
enableViewportScale?: 'yes' | 'no';
|
||||
/** (iOS Only) 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) */
|
||||
/*
|
||||
* (iOS Only) 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)
|
||||
*/
|
||||
allowInlineMediaPlayback?: 'yes' | 'no';
|
||||
/** (iOS Only) Set to yes or no to open the keyboard when form elements receive focus via JavaScript's focus() call (defaults to yes). */
|
||||
keyboardDisplayRequiresUserAction?: 'yes' | 'no';
|
||||
@@ -49,7 +56,7 @@ export interface InAppBrowserOptions {
|
||||
transitionstyle?: 'fliphorizontal' | 'crossdissolve' | 'coververtical';
|
||||
/** (iOS Only) Set to top or bottom (default is bottom). Causes the toolbar to be at the top or bottom of the window. */
|
||||
toolbarposition?: 'top' | 'bottom';
|
||||
/** (Windows only) Set to yes to create the browser control without a border around it.
|
||||
/* (Windows only) Set to yes to create the browser control without a border around it.
|
||||
* Please note that if location=no is also specified, there will be no control presented to user to close IAB window. */
|
||||
fullscreen?: 'yes';
|
||||
|
||||
@@ -74,7 +81,6 @@ export interface InAppBrowserEvent extends Event {
|
||||
* @hidden
|
||||
*/
|
||||
export class InAppBrowserObject {
|
||||
|
||||
private _objectInstance: any;
|
||||
|
||||
/**
|
||||
@@ -88,20 +94,24 @@ export class InAppBrowserObject {
|
||||
* 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.
|
||||
*/
|
||||
constructor(url: string, target?: string, options?: string | InAppBrowserOptions) {
|
||||
constructor(
|
||||
url: string,
|
||||
target?: string,
|
||||
options?: string | InAppBrowserOptions
|
||||
) {
|
||||
try {
|
||||
|
||||
if (options && typeof options !== 'string') {
|
||||
options = Object.keys(options).map((key: string) => `${key}=${(<InAppBrowserOptions>options)[key]}`).join(',');
|
||||
options = Object.keys(options)
|
||||
.map((key: string) => `${key}=${(<InAppBrowserOptions>options)[key]}`)
|
||||
.join(',');
|
||||
}
|
||||
|
||||
this._objectInstance = cordova.InAppBrowser.open(url, target, options);
|
||||
|
||||
} catch (e) {
|
||||
|
||||
window.open(url, target);
|
||||
console.warn('Native: InAppBrowser is not installed or you are running on a browser. Falling back to window.open.');
|
||||
|
||||
console.warn(
|
||||
'Native: InAppBrowser is not installed or you are running on a browser. Falling back to window.open.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,23 +120,20 @@ export class InAppBrowserObject {
|
||||
* if the InAppBrowser was already visible.
|
||||
*/
|
||||
@CordovaInstance({ sync: true })
|
||||
show(): void {
|
||||
}
|
||||
show(): void {}
|
||||
|
||||
/**
|
||||
* Closes the InAppBrowser window.
|
||||
*/
|
||||
@CordovaInstance({ sync: true })
|
||||
close(): void {
|
||||
}
|
||||
close(): void {}
|
||||
|
||||
/**
|
||||
* Hides an InAppBrowser window that is currently shown. Calling this has no effect
|
||||
* if the InAppBrowser was already hidden.
|
||||
*/
|
||||
@CordovaInstance({ sync: true })
|
||||
hide(): void {
|
||||
}
|
||||
hide(): void {}
|
||||
|
||||
/**
|
||||
* Injects JavaScript code into the InAppBrowser window.
|
||||
@@ -134,7 +141,7 @@ export class InAppBrowserObject {
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@CordovaInstance()
|
||||
executeScript(script: { file?: string, code?: string }): Promise<any> {
|
||||
executeScript(script: { file?: string; code?: string }): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -144,7 +151,7 @@ export class InAppBrowserObject {
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@CordovaInstance()
|
||||
insertCSS(css: { file?: string, code?: string }): Promise<any> {
|
||||
insertCSS(css: { file?: string; code?: string }): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -155,10 +162,19 @@ export class InAppBrowserObject {
|
||||
*/
|
||||
@InstanceCheck()
|
||||
on(event: string): Observable<InAppBrowserEvent> {
|
||||
return new Observable<InAppBrowserEvent>((observer: Observer<InAppBrowserEvent>) => {
|
||||
this._objectInstance.addEventListener(event, observer.next.bind(observer));
|
||||
return () => this._objectInstance.removeEventListener(event, observer.next.bind(observer));
|
||||
});
|
||||
return new Observable<InAppBrowserEvent>(
|
||||
(observer: Observer<InAppBrowserEvent>) => {
|
||||
this._objectInstance.addEventListener(
|
||||
event,
|
||||
observer.next.bind(observer)
|
||||
);
|
||||
return () =>
|
||||
this._objectInstance.removeEventListener(
|
||||
event,
|
||||
observer.next.bind(observer)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +218,6 @@ export class InAppBrowserObject {
|
||||
})
|
||||
@Injectable()
|
||||
export class InAppBrowser extends IonicNativePlugin {
|
||||
|
||||
/**
|
||||
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
|
||||
* @param url {string} The URL to load.
|
||||
@@ -212,8 +227,11 @@ export class InAppBrowser extends IonicNativePlugin {
|
||||
* name/value pairs must be separated by a comma. Feature names are case insensitive.
|
||||
* @returns {InAppBrowserObject}
|
||||
*/
|
||||
create(url: string, target?: string, options?: string | InAppBrowserOptions): InAppBrowserObject {
|
||||
create(
|
||||
url: string,
|
||||
target?: string,
|
||||
options?: string | InAppBrowserOptions
|
||||
): InAppBrowserObject {
|
||||
return new InAppBrowserObject(url, target, options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user