Skip to content

Commit 2d06f3b

Browse files
committed
implemented prompt in DialogServce + refactored DialogService. closes #236
1 parent 92d274b commit 2d06f3b

File tree

1 file changed

+56
-42
lines changed

1 file changed

+56
-42
lines changed

angular/services/dialog.service.js

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,58 @@
11
export class DialogService {
2-
constructor($mdDialog) {
3-
'ngInject';
4-
5-
this.$mdDialog = $mdDialog
6-
}
7-
8-
fromTemplate(template, options) {
9-
if (!template) {
10-
return false;
11-
}
12-
13-
if (!options) {
14-
options = {};
15-
}
16-
17-
options.templateUrl = './views/dialogs/' + template + '/' + template + 'dialog.html'
18-
19-
return this.$mdDialog.show(options);
20-
}
21-
22-
hide() {
23-
return this.$mdDialog.hide();
24-
}
25-
26-
alert(title, content) {
27-
this.$mdDialog.show(
28-
this.$mdDialog.alert()
29-
.title(title)
30-
.content(content)
31-
.ok('Ok')
32-
);
33-
}
34-
35-
confirm(title, content) {
36-
return this.$mdDialog.show(
37-
this.$mdDialog.confirm()
38-
.title(title)
39-
.content(content)
40-
.ok('Ok')
41-
.cancel('Cancel')
42-
);
43-
}
2+
constructor($mdDialog) {
3+
'ngInject';
4+
5+
this.$mdDialog = $mdDialog
6+
}
7+
8+
fromTemplate(template, options) {
9+
if (!template) {
10+
return false;
11+
}
12+
13+
if (!options) {
14+
options = {};
15+
}
16+
17+
options.templateUrl = './views/dialogs/' + template + '/' + template + 'dialog.html'
18+
19+
return this.$mdDialog.show(options);
20+
}
21+
22+
hide() {
23+
return this.$mdDialog.hide();
24+
}
25+
26+
alert(title, content) {
27+
var alert = this.$mdDialog.alert()
28+
.title(title)
29+
.content(content)
30+
.ariaLabel(content)
31+
.ok('Ok');
32+
33+
this.$mdDialog.show(alert);
34+
}
35+
36+
confirm(title, content) {
37+
var confirm = this.$mdDialog.confirm()
38+
.title(title)
39+
.content(content)
40+
.ariaLabel(content)
41+
.ok('Ok')
42+
.cancel('Cancel');
43+
44+
return this.$mdDialog.show(confirm);
45+
}
46+
47+
prompt(title, content, placeholder) {
48+
var prompt = this.$mdDialog.prompt()
49+
.title(title)
50+
.textContent(content)
51+
.placeholder(placeholder)
52+
.ariaLabel(placeholder)
53+
.ok('Ok')
54+
.cancel('Cancel');
55+
56+
return this.$mdDialog.show(prompt);
57+
}
4458
}

0 commit comments

Comments
 (0)