From bad4f0c7a1967bc51751138ff351f69287743442 Mon Sep 17 00:00:00 2001 From: Sam Saint-Pettersen Date: Fri, 6 Nov 2015 16:21:16 +0000 Subject: [PATCH 1/9] Create ngbootbox.d.ts --- ngbootbox.d.ts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 ngbootbox.d.ts diff --git a/ngbootbox.d.ts b/ngbootbox.d.ts new file mode 100644 index 0000000000..99d4941d1c --- /dev/null +++ b/ngbootbox.d.ts @@ -0,0 +1,38 @@ +// Type definitions for ngbootbox +// Project: https://github.com/eriktufvesson/ngBootbox +// Definitions by: Sam Saint-Pettersen +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +interface IBootboxDialog { + title?: string; + message?: string; + templateUrl?: string; + locale?: string; + callback?: () => any; + onEscape?: () => any | boolean; + show?: boolean; + backdrop?: boolean; + closeButton?: boolean; + animate?: boolean; + className?: string; + size?: string; + buttons?: BootboxButtonMap; +} + +interface IBootboxService { + alert(msg: string): Promise; + confirm(msg: string): Promise; + prompt(msg: string): Promise; + customDialog(options: IBootboxDialog): void; + setDefaults(options: BootboxDefaultOptions): void; + hideAll(): void; + + addLocale(name: string, values: BootboxLocaleValues): void; + removeLocale(name: string): void; + setLocale(name: string): void; +} + +declare var $ngBootbox: IBootboxService; From 2825966f76c31c366d50f225d6c0acfd0dfb4584 Mon Sep 17 00:00:00 2001 From: Sam Saint-Pettersen Date: Fri, 6 Nov 2015 16:21:48 +0000 Subject: [PATCH 2/9] Rename ngbootbox.d.ts to ngbootbox/ngbootbox.d.ts --- ngbootbox.d.ts => ngbootbox/ngbootbox.d.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ngbootbox.d.ts => ngbootbox/ngbootbox.d.ts (100%) diff --git a/ngbootbox.d.ts b/ngbootbox/ngbootbox.d.ts similarity index 100% rename from ngbootbox.d.ts rename to ngbootbox/ngbootbox.d.ts From de5f7178c6f14cbbf16525dd0dc1f9e3d1c6e34a Mon Sep 17 00:00:00 2001 From: Sam Saint-Pettersen Date: Fri, 6 Nov 2015 16:22:02 +0000 Subject: [PATCH 3/9] Update ngbootbox.d.ts From e7f3e75436523a2c283b9d13fe8c52d117c3db7f Mon Sep 17 00:00:00 2001 From: Sam Saint-Pettersen Date: Fri, 6 Nov 2015 16:23:53 +0000 Subject: [PATCH 4/9] Create ngbootbox-tests.ts --- ngbootbox/ngbootbox-tests.ts | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 ngbootbox/ngbootbox-tests.ts diff --git a/ngbootbox/ngbootbox-tests.ts b/ngbootbox/ngbootbox-tests.ts new file mode 100644 index 0000000000..0b64d63763 --- /dev/null +++ b/ngbootbox/ngbootbox-tests.ts @@ -0,0 +1,50 @@ +/// +/// + +class TestBootboxController { + + constructor(private $scope: angular.IScope, $ngBootbox: IBootboxService) { + + $ngBootbox.alert('An important message!').then(function() { + console.log('Alert closed'); + }); + + $ngBootbox.confirm('A question?').then(function() { + console.log('Confirmed!'); + }, function() { + console.log('Confirm dismissed!'); + }); + + $ngBootbox.prompt('Enter something').then(function(result) { + console.log('Prompt returned: ' + result); + }, function() { + console.log('Prompt dismissed!'); + }); + + var options: IBootboxDialog = { + message: 'This is a message!', + title: 'The title!', + className: 'test-class', + buttons: { + warning: { + label: "Cancel", + className: "btn-warning", + callback: function() { + console.log('warning callback'); + } + }, + success: { + label: "Ok", + className: "btn-success", + callback: function() { + console.log('sucess callback'); + } + } + } + }; + $ngBootbox.customDialog(options); + } +} + +var app = angular.module('testBootbox', ['ngBootbox']); +app.controller('TestBootboxCtrl', ['$scope', '$ngBootbox', TestBootboxController]); From debd1616001fc422abc2c0e802ca396ff8612272 Mon Sep 17 00:00:00 2001 From: Sam Saint-Pettersen Date: Fri, 6 Nov 2015 16:24:24 +0000 Subject: [PATCH 5/9] Update ngbootbox.d.ts --- ngbootbox/ngbootbox.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ngbootbox/ngbootbox.d.ts b/ngbootbox/ngbootbox.d.ts index 99d4941d1c..b81a07501d 100644 --- a/ngbootbox/ngbootbox.d.ts +++ b/ngbootbox/ngbootbox.d.ts @@ -3,8 +3,8 @@ // Definitions by: Sam Saint-Pettersen // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// -/// +/// +/// interface IBootboxDialog { title?: string; From 17c4962083dad92ac297c5b6a1eb030e7e4ccd91 Mon Sep 17 00:00:00 2001 From: Sam Saint-Pettersen Date: Fri, 6 Nov 2015 16:29:57 +0000 Subject: [PATCH 6/9] Update ngbootbox-tests.ts --- ngbootbox/ngbootbox-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ngbootbox/ngbootbox-tests.ts b/ngbootbox/ngbootbox-tests.ts index 0b64d63763..7e8196fec7 100644 --- a/ngbootbox/ngbootbox-tests.ts +++ b/ngbootbox/ngbootbox-tests.ts @@ -1,4 +1,4 @@ -/// +/// /// class TestBootboxController { From 72aebc82130ef7b19566ab203e096e8458f82936 Mon Sep 17 00:00:00 2001 From: Sam Saint-Pettersen Date: Wed, 11 Nov 2015 10:35:06 +0000 Subject: [PATCH 7/9] Update ngbootbox.d.ts --- ngbootbox/ngbootbox.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ngbootbox/ngbootbox.d.ts b/ngbootbox/ngbootbox.d.ts index b81a07501d..4c6233dabe 100644 --- a/ngbootbox/ngbootbox.d.ts +++ b/ngbootbox/ngbootbox.d.ts @@ -6,7 +6,7 @@ /// /// -interface IBootboxDialog { +interface NgBootboxDialog { title?: string; message?: string; templateUrl?: string; @@ -22,7 +22,7 @@ interface IBootboxDialog { buttons?: BootboxButtonMap; } -interface IBootboxService { +interface BootboxService { alert(msg: string): Promise; confirm(msg: string): Promise; prompt(msg: string): Promise; @@ -35,4 +35,4 @@ interface IBootboxService { setLocale(name: string): void; } -declare var $ngBootbox: IBootboxService; +declare var $ngBootbox: BootboxService; From dc6ed0fd0a50890143b41b1f1c601965725260ab Mon Sep 17 00:00:00 2001 From: Sam Saint-Pettersen Date: Wed, 11 Nov 2015 10:35:40 +0000 Subject: [PATCH 8/9] Update ngbootbox.d.ts --- ngbootbox/ngbootbox.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ngbootbox/ngbootbox.d.ts b/ngbootbox/ngbootbox.d.ts index 4c6233dabe..e99e47979b 100644 --- a/ngbootbox/ngbootbox.d.ts +++ b/ngbootbox/ngbootbox.d.ts @@ -26,7 +26,7 @@ interface BootboxService { alert(msg: string): Promise; confirm(msg: string): Promise; prompt(msg: string): Promise; - customDialog(options: IBootboxDialog): void; + customDialog(options: NgBootboxDialog): void; setDefaults(options: BootboxDefaultOptions): void; hideAll(): void; From 3f67d589738d4616ca62583d08df3e6fc2971acf Mon Sep 17 00:00:00 2001 From: Sam Saint-Pettersen Date: Wed, 11 Nov 2015 10:36:16 +0000 Subject: [PATCH 9/9] Update ngbootbox-tests.ts --- ngbootbox/ngbootbox-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ngbootbox/ngbootbox-tests.ts b/ngbootbox/ngbootbox-tests.ts index 7e8196fec7..ec4fb2830d 100644 --- a/ngbootbox/ngbootbox-tests.ts +++ b/ngbootbox/ngbootbox-tests.ts @@ -3,7 +3,7 @@ class TestBootboxController { - constructor(private $scope: angular.IScope, $ngBootbox: IBootboxService) { + constructor(private $scope: angular.IScope, $ngBootbox: BootboxService) { $ngBootbox.alert('An important message!').then(function() { console.log('Alert closed'); @@ -21,7 +21,7 @@ class TestBootboxController { console.log('Prompt dismissed!'); }); - var options: IBootboxDialog = { + var options: NgBootboxDialog = { message: 'This is a message!', title: 'The title!', className: 'test-class',