forked from oitozero/ngSweetAlert
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SweetAlert.js
55 lines (46 loc) · 1.04 KB
/
SweetAlert.js
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
/**
@fileOverview
@toc
*/
'use strict';
angular.module('oitozero.ngSweetAlert', [])
.factory('SweetAlert', [ '$timeout', '$window', function ( $timeout, $window ) {
var swal = $window.swal;
//public methods
var self = {
swal: function ( arg1, arg2, arg3 ) {
$timeout(function(){
if( typeof(arg2) === 'function' ) {
swal( arg1, function(isConfirm){
$timeout( function(){
arg2(isConfirm);
});
}, arg3 );
} else {
swal( arg1, arg2, arg3 );
}
}, 200);
},
success: function(title, message) {
$timeout(function(){
swal( title, message, 'success' );
}, 200);
},
error: function(title, message) {
$timeout(function(){
swal( title, message, 'error' );
}, 200);
},
warning: function(title, message) {
$timeout(function(){
swal( title, message, 'warning' );
}, 200);
},
info: function(title, message) {
$timeout(function(){
swal( title, message, 'info' );
}, 200);
}
};
return self;
}]);