mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
Merge pull request #17119 from DefinitelyTyped/update_cordova-plugin-inappbrowser
[Cordova] Update cordova plugin inappbrowser and batter-status
This commit is contained in:
@@ -1,5 +1,29 @@
|
||||
window.addEventListener('batterystatus',
|
||||
(ev: BatteryStatusEvent) => { console.log('Battery level is ' + ev.level); });
|
||||
function eventCallBack(ev: BatteryStatusEvent) {
|
||||
console.log('Battery level is ' + ev.level);
|
||||
}
|
||||
window.addEventListener('batterystatus', (ev: BatteryStatusEvent) => { console.log('Battery level is ' + ev.level); });
|
||||
window.addEventListener('batterystatus', (ev) => { console.log('Battery level is ' + ev.level); });
|
||||
window.addEventListener('batterycritical', (ev) => { console.log('Battery is critical: ' + ev.level); });
|
||||
window.addEventListener('batterylow', (ev) => { console.log('Battery is low: ' + ev.level); });
|
||||
|
||||
window.addEventListener('batterycritical',
|
||||
() => { alert('Battery is critical low!'); });
|
||||
window.addEventListener('baterystatus', eventCallBack);
|
||||
window.addEventListener('batterycritical', eventCallBack);
|
||||
window.addEventListener('batterylow', eventCallBack);
|
||||
|
||||
window.removeEventListener('batterystatus', eventCallBack);
|
||||
window.removeEventListener('batterycritical', eventCallBack);
|
||||
window.removeEventListener('batterylow', eventCallBack);
|
||||
|
||||
window.addEventListener('batterycritical', () => { alert('Battery is critical low!'); });
|
||||
window.addEventListener('batterylow', () => { alert('Battery is low!'); });
|
||||
|
||||
function batteryCriticalCallback() {
|
||||
alert('Battery is critical low!');
|
||||
}
|
||||
|
||||
function batteryLowCallback() {
|
||||
alert('Battery is critical low!');
|
||||
}
|
||||
|
||||
window.addEventListener('batterycritical', batteryCriticalCallback);
|
||||
window.addEventListener('batterylow', batteryLowCallback);
|
||||
122
types/cordova-plugin-battery-status/index.d.ts
vendored
122
types/cordova-plugin-battery-status/index.d.ts
vendored
@@ -4,116 +4,28 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
//
|
||||
// Copyright (c) Microsoft Open Technologies Inc
|
||||
// Licensed under the MIT license.
|
||||
// Licensed under the MIT license.
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
interface WindowEventMap {
|
||||
/**
|
||||
* batterystatus: event fires when the percentage of battery charge changes by at least 1 percent, or if the device is plugged in or unplugged.
|
||||
*/
|
||||
"batterystatus" : BatteryStatusEvent;
|
||||
/**
|
||||
* batterycritical: event fires when the percentage of battery charge has reached the critical battery threshold. The value is device-specific.
|
||||
*/
|
||||
"batterycritical": BatteryStatusEvent;
|
||||
/**
|
||||
* batterylow: event fires when the percentage of battery charge has reached the low battery threshold, device-specific value.
|
||||
*/
|
||||
"batterylow": BatteryStatusEvent;
|
||||
}
|
||||
|
||||
interface Window {
|
||||
onbatterystatus: (type: BatteryStatusEvent) => void;
|
||||
onbatterycritical: (type: BatteryStatusEvent) => void;
|
||||
onbatterylow: (type: BatteryStatusEvent) => void;
|
||||
/**
|
||||
* Adds a listener for an event from the BatteryStatus plugin.
|
||||
* @param type the event to listen for
|
||||
* batterystatus: event fires when the percentage of battery charge
|
||||
* changes by at least 1 percent, or if the device is plugged in or unplugged.
|
||||
* batterycritical: event fires when the percentage of battery charge has reached
|
||||
* the critical battery threshold. The value is device-specific.
|
||||
* batterylow: event fires when the percentage of battery charge has
|
||||
* reached the low battery threshold, device-specific value.
|
||||
* @param listener the function that executes when the event fires. The function is
|
||||
* passed an BatteryStatusEvent object as a parameter.
|
||||
*/
|
||||
addEventListener(type: "batterystatus", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
|
||||
/**
|
||||
* Adds a listener for an event from the BatteryStatus plugin.
|
||||
* @param type the event to listen for
|
||||
* batterystatus: event fires when the percentage of battery charge
|
||||
* changes by at least 1 percent, or if the device is plugged in or unplugged.
|
||||
* batterycritical: event fires when the percentage of battery charge has reached
|
||||
* the critical battery threshold. The value is device-specific.
|
||||
* batterylow: event fires when the percentage of battery charge has
|
||||
* reached the low battery threshold, device-specific value.
|
||||
* @param listener the function that executes when the event fires. The function is
|
||||
* passed an BatteryStatusEvent object as a parameter.
|
||||
*/
|
||||
addEventListener(type: "batterycritical", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
|
||||
/**
|
||||
* Adds a listener for an event from the BatteryStatus plugin.
|
||||
* @param type the event to listen for
|
||||
* batterystatus: event fires when the percentage of battery charge
|
||||
* changes by at least 1 percent, or if the device is plugged in or unplugged.
|
||||
* batterycritical: event fires when the percentage of battery charge has reached
|
||||
* the critical battery threshold. The value is device-specific.
|
||||
* batterylow: event fires when the percentage of battery charge has
|
||||
* reached the low battery threshold, device-specific value.
|
||||
* @param listener the function that executes when the event fires. The function is
|
||||
* passed an BatteryStatusEvent object as a parameter.
|
||||
*/
|
||||
addEventListener(type: "batterylow", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
|
||||
/**
|
||||
* Adds a listener for an event from the BatteryStatus plugin.
|
||||
* @param type the event to listen for
|
||||
* batterystatus: event fires when the percentage of battery charge
|
||||
* changes by at least 1 percent, or if the device is plugged in or unplugged.
|
||||
* batterycritical: event fires when the percentage of battery charge has reached
|
||||
* the critical battery threshold. The value is device-specific.
|
||||
* batterylow: event fires when the percentage of battery charge has
|
||||
* reached the low battery threshold, device-specific value.
|
||||
* @param listener the function that executes when the event fires. The function is
|
||||
* passed an BatteryStatusEvent object as a parameter.
|
||||
*/
|
||||
addEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
/**
|
||||
* Removes a listener for an event from the BatteryStatus plugin.
|
||||
* @param type The event to stop listening for.
|
||||
* batterystatus: event fires when the percentage of battery charge
|
||||
* changes by at least 1 percent, or if the device is plugged in or unplugged.
|
||||
* batterycritical: event fires when the percentage of battery charge has reached
|
||||
* the critical battery threshold. The value is device-specific.
|
||||
* batterylow: event fires when the percentage of battery charge has
|
||||
* reached the low battery threshold, device-specific value.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an BatteryStatusEvent object as a parameter.
|
||||
*/
|
||||
removeEventListener(type: "batterystatus", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
|
||||
/**
|
||||
* Removes a listener for an event from the BatteryStatus plugin.
|
||||
* @param type The event to stop listening for.
|
||||
* batterystatus: event fires when the percentage of battery charge
|
||||
* changes by at least 1 percent, or if the device is plugged in or unplugged.
|
||||
* batterycritical: event fires when the percentage of battery charge has reached
|
||||
* the critical battery threshold. The value is device-specific.
|
||||
* batterylow: event fires when the percentage of battery charge has
|
||||
* reached the low battery threshold, device-specific value.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an BatteryStatusEvent object as a parameter.
|
||||
*/
|
||||
removeEventListener(type: "batterycritical", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
|
||||
/**
|
||||
* Removes a listener for an event from the BatteryStatus plugin.
|
||||
* @param type The event to stop listening for.
|
||||
* batterystatus: event fires when the percentage of battery charge
|
||||
* changes by at least 1 percent, or if the device is plugged in or unplugged.
|
||||
* batterycritical: event fires when the percentage of battery charge has reached
|
||||
* the critical battery threshold. The value is device-specific.
|
||||
* batterylow: event fires when the percentage of battery charge has
|
||||
* reached the low battery threshold, device-specific value.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an BatteryStatusEvent object as a parameter.
|
||||
*/
|
||||
removeEventListener(type: "batterylow", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
|
||||
/**
|
||||
* Removes a listener for an event from the BatteryStatus plugin.
|
||||
* @param type The event to stop listening for.
|
||||
* batterystatus: event fires when the percentage of battery charge
|
||||
* changes by at least 1 percent, or if the device is plugged in or unplugged.
|
||||
* batterycritical: event fires when the percentage of battery charge has reached
|
||||
* the critical battery threshold. The value is device-specific.
|
||||
* batterylow: event fires when the percentage of battery charge has
|
||||
* reached the low battery threshold, device-specific value.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an BatteryStatusEvent object as a parameter.
|
||||
*/
|
||||
removeEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
/** Object, that passed into battery event listener */
|
||||
|
||||
@@ -5,7 +5,28 @@
|
||||
// is similar to native window.open signature, so the compiler can's
|
||||
// select proper overload, but we cast result to InAppBrowser manually.
|
||||
var iab = <InAppBrowser>window.open('google.com', '_self');
|
||||
|
||||
iab.addEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Start opening ' + ev.url); });
|
||||
iab.addEventListener('loadstart', (ev) => { console.log('loadstart' + ev.url); });
|
||||
iab.addEventListener('loadstop', (ev) => { console.log('loadstop' + ev.code); });
|
||||
iab.addEventListener('loaderror', (ev) => { console.log('loaderror' + ev.code); });
|
||||
iab.addEventListener('exit', (ev) => { console.log('exit' + ev.code); });
|
||||
|
||||
function inAppBrowserCallBack(ev: InAppBrowserEvent) {
|
||||
console.log('InAppBrowser callback ' + ev.url);
|
||||
}
|
||||
|
||||
iab.addEventListener('loadstart', inAppBrowserCallBack);
|
||||
iab.addEventListener('loadstart', inAppBrowserCallBack);
|
||||
iab.addEventListener('loadstop', inAppBrowserCallBack);
|
||||
iab.addEventListener('loaderror', inAppBrowserCallBack);
|
||||
iab.addEventListener('exit', inAppBrowserCallBack);
|
||||
|
||||
iab.removeEventListener('loadstart', inAppBrowserCallBack);
|
||||
iab.removeEventListener('loadstop', inAppBrowserCallBack);
|
||||
iab.removeEventListener('loaderror', inAppBrowserCallBack);
|
||||
iab.removeEventListener('exit', inAppBrowserCallBack);
|
||||
|
||||
iab.show();
|
||||
iab.executeScript(
|
||||
{ code: "console.log('Injected script in action')" },
|
||||
|
||||
96
types/cordova-plugin-inappbrowser/index.d.ts
vendored
96
types/cordova-plugin-inappbrowser/index.d.ts
vendored
@@ -5,6 +5,7 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Open Technologies Inc
|
||||
// Licensed under the MIT license.
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
interface Window {
|
||||
/**
|
||||
@@ -57,59 +58,14 @@ interface InAppBrowser extends Window {
|
||||
// addEventListener overloads
|
||||
/**
|
||||
* Adds a listener for an event from the InAppBrowser.
|
||||
* @param type the event to listen for
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* @param type loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
addEventListener(type: "loadstart", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Adds a listener for an event from the InAppBrowser.
|
||||
* @param type the event to listen for
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
addEventListener(type: "loadstop", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Adds a listener for an event from the InAppBrowser.
|
||||
* @param type the event to listen for
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
addEventListener(type: "loaderror", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Adds a listener for an event from the InAppBrowser.
|
||||
* @param type the event to listen for
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
addEventListener(type: "exit", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Adds a listener for an event from the InAppBrowser.
|
||||
* @param type the event to listen for
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an Event object as a parameter.
|
||||
*/
|
||||
addEventListener(type: string, callback: (event: Event) => void): void;
|
||||
addEventListener(type: "loadstart" | "loadstop" | "loaderror" | "exit", callback: (event: InAppBrowserEvent) => void): void;
|
||||
// removeEventListener overloads
|
||||
/**
|
||||
* Removes a listener for an event from the InAppBrowser.
|
||||
@@ -121,51 +77,7 @@ interface InAppBrowser extends Window {
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
removeEventListener(type: "loadstart", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Removes a listener for an event from the InAppBrowser.
|
||||
* @param type The event to stop listening for.
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
removeEventListener(type: "loadstop", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Removes a listener for an event from the InAppBrowser.
|
||||
* @param type The event to stop listening for.
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
removeEventListener(type: "loaderror", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Removes a listener for an event from the InAppBrowser.
|
||||
* @param type The event to stop listening for.
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
removeEventListener(type: "exit", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/**
|
||||
* Removes a listener for an event from the InAppBrowser.
|
||||
* @param type The event to stop listening for.
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an Event object as a parameter.
|
||||
*/
|
||||
removeEventListener(type: string, callback: (event: Event) => void): void;
|
||||
removeEventListener(type: "loadstart" | "loadstop" | "loaderror" | "exit", callback: (event: InAppBrowserEvent) => void): void;
|
||||
/** Closes the InAppBrowser window. */
|
||||
close(): void;
|
||||
/** Hides the InAppBrowser window. Calling this has no effect if the InAppBrowser was already hidden. */
|
||||
|
||||
Reference in New Issue
Block a user