diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index c645bca656..723bb1d2b8 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -49,6 +49,7 @@ All definitions files include a header with the author and editors, so at some p * [Commander](http://github.com/visionmedia/commander.js) (by [Marcelo Dezem](https://github.com/mdezem)) * [configstore](http://github.com/yeoman/configstore) (by [Bart van der Schoor](https://github.com/Bartvds)) * [Cordova](http://cordova.apache.org) (by [Microsoft Open Technologies, Inc.](http://msopentech.com/)) +* [Cordovarduino](https://github.com/stereolux/cordovarduino) (by [Hendrik Maus](https://github.com/hendrikmaus)) * [Couchbase / Couchnode](https://github.com/couchbase/couchnode) (by [Basarat Ali Syed](https://github.com/basarat)) * [Crossfilter](https://github.com/square/crossfilter) (by [Schmulik Raskin](https://github.com/schmuli)) * [crypto-js](https://code.google.com/p/crypto-js/) (by [Gia Bảo @ Sân Đình](https://github.com/giabao)). @see [cryptojs.d.ts repo](https://github.com/giabao/cryptojs.d.ts) @@ -122,6 +123,7 @@ All definitions files include a header with the author and editors, so at some p * [iCheck](http://damirfoy.com/iCheck/) (by [Dániel Tar](https://github.com/qcz)) * [Impress.js](https://github.com/bartaz/impress.js) (by [Boris Yankov](https://github.com/borisyankov)) * [Imagemagick](http://github.com/rsms/node-imagemagick) (by [Carlos Ballesteros Velasco](https://github.com/soywiz)) +* [Ionic-Cordova](https://github.com/driftyco/) (by [Hendrik Maus](https://github.com/hendrikmaus)) * [iScroll](http://cubiq.org/iscroll-4) (by [Boris Yankov](https://github.com/borisyankov) and [Christiaan Rakowski](https://github.com/csrakowski)) * [IxJS (Interactive extensions)](https://github.com/Reactive-Extensions/IxJS) (by [Igor Oleinikov](https://github.com/Igorbek)) * [jake](https://github.com/mde/jake) (by [Kon](http://phyzkit.net/)) diff --git a/cordova-ionic/cordova-ionic-tests.ts b/cordova-ionic/cordova-ionic-tests.ts new file mode 100644 index 0000000000..69d1a3d829 --- /dev/null +++ b/cordova-ionic/cordova-ionic-tests.ts @@ -0,0 +1,10 @@ +/// +/// + +// Keyboard +cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); +cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false); +cordova.plugins.Keyboard.close(); +cordova.plugins.Keyboard.disableScroll(true); +cordova.plugins.Keyboard.disableScroll(false); +console.log(cordova.plugins.Keyboard.isVisible); diff --git a/cordova-ionic/cordova-ionic.d.ts b/cordova-ionic/cordova-ionic.d.ts new file mode 100644 index 0000000000..c9b1e635b3 --- /dev/null +++ b/cordova-ionic/cordova-ionic.d.ts @@ -0,0 +1,14 @@ +// Type definitions for Ionic Cordova plugins +// Project: https://github.com/driftyco +// Definitions by: Hendrik Maus +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface Cordova { + plugins:Plugins; +} + +interface Plugins { + Keyboard:Ionic.Keyboard; +} diff --git a/cordova-ionic/plugins/keyboard.d.ts b/cordova-ionic/plugins/keyboard.d.ts new file mode 100644 index 0000000000..4ff9e293d5 --- /dev/null +++ b/cordova-ionic/plugins/keyboard.d.ts @@ -0,0 +1,33 @@ +// Type definitions for Cordova Keyboard plugin +// Project: https://github.com/driftyco/ionic-plugins-keyboard +// Definitions by: Hendrik Maus +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Ionic { + interface Keyboard { + + /** + * Hide the keyboard accessory bar with the next, previous and done buttons. + * + * @param hide + */ + hideKeyboardAccessoryBar(hide:boolean): void; + + /** + * Close the keyboard if it is open. + */ + close(): void; + + /** + * Disable native scrolling, useful if you are using JavaScript to scroll + * + * @param disbale + */ + disableScroll(disbale:boolean): void; + + /** + * Whether or not the keyboard is currently visible. + */ + isVisible: boolean; + } +} diff --git a/cordovarduino/cordovarduino-tests.ts b/cordovarduino/cordovarduino-tests.ts new file mode 100644 index 0000000000..a4fd608789 --- /dev/null +++ b/cordovarduino/cordovarduino-tests.ts @@ -0,0 +1,38 @@ +/// + +serial.requestPermission(function success() {}, function error() {}); +serial.open({}, function success() {}, function error() {}); +serial.write('data_string', function success() {}, function error() {}); +serial.read(function success() {}, function error() {}); +serial.registerReadCallback( + function success(data:any) { + var view = new Uint8Array(data); + console.log(view); + }, + function error() { + new Error("Failed to register read callback"); + }); +serial.close(function success() {}, function error() {}); + +var errorCallback = function (message:string) { + alert('Error: ' + message); +}; + +serial.requestPermission( + function (successMessage:string) { + serial.open( + {baudRate: 9600}, + function (successMessage:string) { + serial.write( + '1', + function (successMessage:string) { + alert(successMessage); + }, + errorCallback + ); + }, + errorCallback + ); + }, + errorCallback +); diff --git a/cordovarduino/cordovarduino.d.ts b/cordovarduino/cordovarduino.d.ts new file mode 100644 index 0000000000..0fccff2ad9 --- /dev/null +++ b/cordovarduino/cordovarduino.d.ts @@ -0,0 +1,84 @@ +// Type definitions for Cordovarduino plugin +// Project: https://github.com/stereolux/cordovarduino +// Definitions by: Hendrik Maus +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Cordovardunio { + interface Serial { + /** + * Request permission to interact with the serial port. + * + * @param successCallback Function to call on success + * @param errorCallback Function to call on error + */ + requestPermission(successCallback:Function, errorCallback:Function): void; + + /** + * Open a connection. + * + * @param opts SerialOptions object + * @param successCallback Function to call on success + * @param errorCallback Function to call on error + */ + open(opts:SerialOptions, successCallback:Function, errorCallback:Function): void + + /** + * Write to the serial port. + * + * @param data String data to write to serial port + * @param successCallback Function to call on success + * @param errorCallback Function to call on error + */ + write(data:string, successCallback:Function, errorCallback:Function): void; + + /** + * Read from the serial port. + * + * @param successCallback Function to call on success + * @param errorCallback Function to call on error + */ + read(successCallback:Function, errorCallback:Function): void; + + /** + * Close connection. + * + * @param successCallback Function to call on success + * @param errorCallback Function to call on error + */ + close(successCallback:Function, errorCallback:Function): void; + + /** + * Register a callback for the driver reading incoming data from the serial device + * + * @param successCallback Function to call on success + * @param errorCallback Function to call on error + */ + registerReadCallback(successCallback:Function, errorCallback:Function): void; + } + + interface SerialOptions { + /** + * @defaultValue 9600 + */ + baudRate?: number; + + /** + * @defaultValue 8 + */ + dataBits?: number; + + /** + * @defaultValue 1 + */ + stopBits?: number; + + /** + * @defaultValue 0 + */ + parity?: number; + } +} + + +// Plugin will be surfaced as window.serial +declare var serial:Cordovardunio.Serial;