diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index cd8bb9ff5..52c592cc3 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -19,6 +19,7 @@ All definitions files include a header with the author and editors, so at some p * [Angular Hotkeys](https://github.com/chieffancypants/angular-hotkeys/) (by [Jason Zhao](https://github.com/jlz27)) * [angular-http-auth](https://github.com/witoldsz/angular-http-auth) (by [vvakame](https://github.com/vvakame)) * [Angular Protractor](https://github.com/angular/protractor) (by [Bill Armstrong](https://github.com/BillArmstrong)) +* [Angular notify](https://github.com/cgross/angular-notify) (by [Suwato](https://github.com/Suwato)) * [Angular Translate](http://pascalprecht.github.io/angular-translate/) (by [Michel Salib](https://github.com/michelsalib)) * [Angular UI Bootstrap](http://angular-ui.github.io/bootstrap) (by [Brian Surowiec](https://github.com/xt0rted)) * [any-db](https://github.com/grncdr/node-any-db) (by [Rogier Schouten](https://github.com/rogier-schouten)) diff --git a/angular-notify/angular-notify-tests.ts b/angular-notify/angular-notify-tests.ts new file mode 100644 index 000000000..d5e52b1d1 --- /dev/null +++ b/angular-notify/angular-notify-tests.ts @@ -0,0 +1,31 @@ +/// + +var myapp = angular.module("myapp", ["cgNotify"]); + +myapp.controller("MyController", ["$scope", "cgNotify", + function ($scope:ng.IScope, notify:ng.cgNotify.INotifyService) { // <-- Inject notify + + var notifyObj = notify("Your notification message"); // <-- Call notify with your message + notifyObj.close(); + + notify.config({ + startTop: 10, + verticalSpacing: 15, + duration: 10000, + templateUrl: "angular-notify.html", + position: "center", + container: document.body + }); + + notify( { + message: "My message", + templateUrl: "my_template.html", + position: "center", + container: document.body, + classes: "", // <-- CSS class names + $scope: $scope + }); // <-- Call notify with your message + option + + notify.closeAll(); + } +]); \ No newline at end of file diff --git a/angular-notify/angular-notify.d.ts b/angular-notify/angular-notify.d.ts new file mode 100644 index 000000000..bbb7c1e6b --- /dev/null +++ b/angular-notify/angular-notify.d.ts @@ -0,0 +1,116 @@ +// Type definitions for angular-notify 2.0.2 +// Project: https://github.com/cgross/angular-notify +// Definitions by: Suwato +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module ng.cgNotify { + + interface INotifyService { + + /** + * The notify function can either be passed a string or an object. + * This function will return an object with a close() method and a message property. + * @param message + */ + (message:string):INotify; + + /** + * When passing an object, the object parameters can be: + * @param option + */ + (option:{ + /** + * Required. The message to show. + */ + message : string; + + /** + * Optional. A custom template for the UI of the message. + */ + templateUrl? : string; + + /** + * Optional. A list of custom CSS classes to apply to the message element. + */ + classes? : string; + + /** + * Optional. A string containing any valid Angular HTML which will be shown instead of the regular message text. + * The string must contain one root element like all valid Angular HTML templates (so wrap everything in a ). + */ + messageTemplate? : string; + + /** + * Optional. A valid Angular scope object. The scope of the template will be created by calling $new() on this scope. + */ + $scope? : ng.IScope; + + /** + * Optional. Currently center and right are the only acceptable values. + */ + position? : string; + + /** + * Optional. Element that contains each notification. Defaults to document.body. + */ + container? : any; + }):INotify; + + + /** + * Call config to set the default configuration options for angular-notify. + * The following options may be specified in the given object: + * @param option + */ + config(option:{ + /** + * The default duration (in milliseconds) of each message. A duration of 0 will prevent messages from closing automatically. + */ + duration? : number; + + /** + * The Y pixel value where messages will be shown. + */ + startTop? : number; + + /** + * The number of pixels that should be reserved between messages vertically. + */ + verticalSpacing? : number; + + /** + * The default message template. + */ + templateUrl? : string; + + /** + * The default position of each message. Currently only center and right are the supported values. + */ + position? : string; + + /** + * The default element that contains each notification. Defaults to document.body. + */ + container? : any; + }):void; + + /** + * Closes all currently open notifications. + */ + closeAll():void; + } + + interface INotify{ + /** + * The message to show. + */ + message:string; + + /** + * Close this open notifications. + */ + close():void; + } +} \ No newline at end of file