forked from colmena/colmena
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.js
More file actions
72 lines (58 loc) · 1.57 KB
/
core.js
File metadata and controls
72 lines (58 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
'use strict'
import angular from 'angular'
function CoreService (ENV, SweetAlert, ngToast) {
this.env = ENV
this.alert = (title, text) => {
SweetAlert.swal(title, text)
}
this.alertSuccess = (title, text) => {
SweetAlert.swal(title, text, 'success')
}
this.alertError = (title, text) => {
SweetAlert.swal(title, text, 'error')
}
this.alertWarning = (title, text) => {
SweetAlert.swal(title, text, 'warning')
}
this.alertInfo = (title, text) => {
SweetAlert.swal(title, text, 'info')
}
this.confirm = (title, text, successCb, cancelCb) => {
const config = {
title: title,
text: text,
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#DD6B55',
}
this._swal(config, successCb, cancelCb)
}
this._swal = (config, successCb, cancelCb) => {
SweetAlert.swal(config, (confirmed) => {
if (confirmed) {
successCb()
} else {
cancelCb()
}
})
}
this.toastSuccess = (title, text) => ngToast.create({
className: 'success',
content: `<b>${title}</b><br />${text}`,
})
this.toastError = (title, text) => ngToast.create({
className: 'danger',
content: `<b>${title}</b><br />${text}`,
})
this.toastWarning = (title, text) => ngToast.create({
className: 'warning',
content: `<b>${title}</b><br />${text}`,
})
this.toastInfo = (title, text) => ngToast.create({
className: 'info',
content: `<b>${title}</b><br />${text}`,
})
}
angular
.module('com.module.core.services.core', [])
.service('CoreService', CoreService)