-
Notifications
You must be signed in to change notification settings - Fork 10
/
Alert.js
executable file
·81 lines (78 loc) · 2.16 KB
/
Alert.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
(function(){
'use strict';
Alert.$inject = []
function Alert(){
return {
$get: function(){
return this;
},
__config: {
warn: {
icon: 'glyphicon glyphicon-warning-sign',
type: 'warning'
},
danger: {
icon: 'glyphicon glyphicon-exclamation-sign',
type: 'danger'
},
success: {
icon:'glyphicon glyphicon-ok',
type: 'success'
},
info: {
icon: 'glyphicon glyphicon-info-sign',
type: 'info'
}
},
_notify: function(type,title,message,options){
var config = this.__config[type]
, offset = options.offset || 50
, timer = options.timer || 100
, delay = options.delay || 6000
, alowDismiss = options.alowDismiss || true
, animationEnter = options.animationEnter || 'animated bounceInRight'
, animationExit = options.animationExit || 'animated bounceOutRight';
$.notify({
icon: config.icon,
title: title,
message: message
},{
type: type,
offset: offset,
timer: timer,
delay: delay,
alow_dismiss: alowDismiss,
z_index: 1500,
animate: {
enter: animationEnter,
exit: animationExit
},
template: '<div data-notify="container" class="col-xs-9 col-sm-3 alert alert-{0}" role="alert">' +
'<button type="button" aria-hidden="true" class="close" data-notify="dismiss">×</button>' +
'<span data-notify="icon"></span> ' +
'<span data-notify="title"><b>{1}</b></span><br> ' +
'<span data-notify="message">{2}</span>' +
'</div>'
})
},
createWarningMessage: function(title,message,options){
if(!options) options = {};
this._notify('warn',title,message,options);
},
createDangerMessage: function(title,message,options){
if(!options) options = {};
this._notify('danger',title,message,options);
},
createSuccessMessage: function(title,message,options){
if(!options) options = {};
this._notify('success',title,message,options);
},
createInfoMessage: function(title,message,options){
if(!options) options = {};
this._notify('info',title,message,options);
}
}
}
angular.module('gumga.services.alert',[])
.provider('GumgaAlert',Alert);
})();