mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-04-13 00:00:10 +08:00
@@ -1,6 +1,11 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CordovaInstance, InstanceCheck, IonicNativePlugin, Plugin } from '@ionic-native/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import {
|
||||
CordovaInstance,
|
||||
InstanceCheck,
|
||||
IonicNativePlugin,
|
||||
Plugin
|
||||
} from '@ionic-native/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
declare const cordova: any;
|
||||
|
||||
@@ -71,15 +76,24 @@ export interface ThemeableBrowserOptions {
|
||||
* @hidden
|
||||
*/
|
||||
export class ThemeableBrowserObject {
|
||||
|
||||
private _objectInstance: any;
|
||||
|
||||
constructor(url: string, target: string, styleOptions: ThemeableBrowserOptions) {
|
||||
constructor(
|
||||
url: string,
|
||||
target: string,
|
||||
styleOptions: ThemeableBrowserOptions
|
||||
) {
|
||||
try {
|
||||
this._objectInstance = cordova.ThemeableBrowser.open(url, target, styleOptions);
|
||||
this._objectInstance = cordova.ThemeableBrowser.open(
|
||||
url,
|
||||
target,
|
||||
styleOptions
|
||||
);
|
||||
} catch (e) {
|
||||
window.open(url);
|
||||
console.warn('Native: ThemeableBrowser is not installed or you are running on a browser. Falling back to window.open.');
|
||||
console.warn(
|
||||
'Native: ThemeableBrowser is not installed or you are running on a browser. Falling back to window.open.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,22 +102,19 @@ export class ThemeableBrowserObject {
|
||||
* if the browser was already visible.
|
||||
*/
|
||||
@CordovaInstance({ sync: true })
|
||||
show(): void {
|
||||
}
|
||||
show(): void {}
|
||||
|
||||
/**
|
||||
* Closes the browser window.
|
||||
*/
|
||||
@CordovaInstance({ sync: true })
|
||||
close(): void {
|
||||
}
|
||||
close(): void {}
|
||||
|
||||
/**
|
||||
* Reloads the current page
|
||||
*/
|
||||
@CordovaInstance({ sync: true })
|
||||
reload(): void {
|
||||
}
|
||||
reload(): void {}
|
||||
|
||||
/**
|
||||
* Injects JavaScript code into the browser window.
|
||||
@@ -111,7 +122,7 @@ export class ThemeableBrowserObject {
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@CordovaInstance()
|
||||
executeScript(script: { file?: string, code?: string }): Promise<any> {
|
||||
executeScript(script: { file?: string; code?: string }): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -121,7 +132,7 @@ export class ThemeableBrowserObject {
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@CordovaInstance()
|
||||
insertCss(css: { file?: string, code?: string }): Promise<any> {
|
||||
insertCss(css: { file?: string; code?: string }): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -133,12 +144,18 @@ export class ThemeableBrowserObject {
|
||||
*/
|
||||
@InstanceCheck({ observable: true })
|
||||
on(event: string): Observable<any> {
|
||||
return new Observable<any>((observer) => {
|
||||
this._objectInstance.addEventListener(event, observer.next.bind(observer));
|
||||
return () => this._objectInstance.removeEventListener(event, observer.next.bind(observer));
|
||||
return new Observable<any>(observer => {
|
||||
this._objectInstance.addEventListener(
|
||||
event,
|
||||
observer.next.bind(observer)
|
||||
);
|
||||
return () =>
|
||||
this._objectInstance.removeEventListener(
|
||||
event,
|
||||
observer.next.bind(observer)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,11 +248,20 @@ export class ThemeableBrowserObject {
|
||||
plugin: 'cordova-plugin-themeablebrowser',
|
||||
pluginRef: 'cordova.ThemeableBrowser',
|
||||
repo: 'https://github.com/initialxy/cordova-plugin-themeablebrowser',
|
||||
platforms: ['Amazon Fire OS', 'Android', 'Blackberry 10', 'Browser', 'FirefoxOS', 'iOS', 'Ubuntu', 'Windows', 'Windows Phone']
|
||||
platforms: [
|
||||
'Amazon Fire OS',
|
||||
'Android',
|
||||
'Blackberry 10',
|
||||
'Browser',
|
||||
'FirefoxOS',
|
||||
'iOS',
|
||||
'Ubuntu',
|
||||
'Windows',
|
||||
'Windows Phone'
|
||||
]
|
||||
})
|
||||
@Injectable()
|
||||
export class ThemeableBrowser extends IonicNativePlugin {
|
||||
|
||||
/**
|
||||
* Creates a browser instance
|
||||
* @param url {string} URL to open
|
||||
@@ -243,8 +269,11 @@ export class ThemeableBrowser extends IonicNativePlugin {
|
||||
* @param styleOptions {ThemeableBrowserOptions} Themeable browser options
|
||||
* @returns {ThemeableBrowserObject}
|
||||
*/
|
||||
create(url: string, target: string, styleOptions: ThemeableBrowserOptions): ThemeableBrowserObject {
|
||||
create(
|
||||
url: string,
|
||||
target: string,
|
||||
styleOptions: ThemeableBrowserOptions
|
||||
): ThemeableBrowserObject {
|
||||
return new ThemeableBrowserObject(url, target, styleOptions);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user