cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [3/5] cordova-plugin-battery-status git commit: CB-12369: Add plugin typings from DefinitelyTyped
Date Fri, 03 Mar 2017 00:00:37 GMT
CB-12369: Add plugin typings from DefinitelyTyped

 This closes #49


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/commit/c12bd1a8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/tree/c12bd1a8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/diff/c12bd1a8

Branch: refs/heads/1.2.x
Commit: c12bd1a8336c14303a7aa86b4210071ec947f7b6
Parents: 125dfd9
Author: Nikita Matrosov <v-nimatr@microsoft.com>
Authored: Thu Jan 19 15:48:14 2017 +0300
Committer: Vladimir Kotikov <kotikov.vladimir@gmail.com>
Committed: Fri Jan 20 11:49:13 2017 +0300

----------------------------------------------------------------------
 package.json     |   1 +
 types/index.d.ts | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 126 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/c12bd1a8/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 15ee322..aab5fe3 100644
--- a/package.json
+++ b/package.json
@@ -2,6 +2,7 @@
   "name": "cordova-plugin-battery-status",
   "version": "1.2.3-dev",
   "description": "Cordova Battery Plugin",
+  "types": "./types/index.d.ts",
   "cordova": {
     "id": "cordova-plugin-battery-status",
     "platforms": [

http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status/blob/c12bd1a8/types/index.d.ts
----------------------------------------------------------------------
diff --git a/types/index.d.ts b/types/index.d.ts
new file mode 100644
index 0000000..9baedc8
--- /dev/null
+++ b/types/index.d.ts
@@ -0,0 +1,125 @@
+// Type definitions for Apache Cordova BatteryStatus plugin
+// Project: https://github.com/apache/cordova-plugin-battery-status
+// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// 
+// Copyright (c) Microsoft Open Technologies Inc
+// Licensed under the MIT license. 
+
+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 */
+interface BatteryStatusEvent extends Event {
+	/* The percentage of battery charge (0-100). */
+    level: number;
+	/* A boolean that indicates whether the device is plugged in. */
+    isPlugged: boolean;
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message