notification.js
1.25 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
define('notification', ['components/common', 'jquery.jgrowl', 'css!jgrowl_css'], function(common) {
var constants = SystemEnv.getHtmlNoteName;
var msgTemplate = "\
<div class='alert-icon'><i class='iconfont {{icon}}'></i></div>\
<h4 class='alert-title'>{{title}}</h4>\
<div class='alert-content'>\
<p>{{content}}</p>\
</div>\
";
$.jGrowl.defaults.closerTemplate = ""; // 隐藏 closeAll 按钮
function showNotification(content, keywords) {
keywords.content = content;
$.jGrowl({
message: common.tempEngine(msgTemplate, keywords),
group: 'alert-' + keywords.type,
life: 2000
});
}
return {
success: function(content) {
content = content || constants(4714); // 操作成功
showNotification(content, {
type: 'success',
title: constants(4705), // 成功
icon: 'icon-check'
});
},
error: function(content) {
content = content || constants(4715); // 操作失败
showNotification(content, {
type: 'error',
title: constants(4706), // 失败
icon: 'icon-times'
});
}
}
});