FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
atom/src/notification-manager.coffee at master · onnodejong/atom · GitHub
onnodejong
/
atom
Public
forked from
atom/atom
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
atom
/
src
/
notification-manager.coffee
Copy path
More file actions
More file actions
Latest commit
History
History
History
119 lines (104 loc) · 4.42 KB
Breadcrumbs
atom
/
src
/
notification-manager.coffee
Copy path
File metadata and controls
119 lines (104 loc) · 4.42 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
{
Emitter
,
Disposable
}
=
require
'
event-kit
'
Notification
=
require
'
../src/notification
'
#
Public: A notification manager used to create {Notification}s to be shown
#
to the user.
#
#
An instance of this class is always available as the `atom.notifications`
#
global.
module
.
exports
=
class
NotificationManager
constructor
:
->
@notifications
=
[]
@emitter
=
new
Emitter
###
Section: Events
###
#
Public: Invoke the given callback after a notification has been added.
#
#
* `callback` {Function} to be called after the notification is added.
#
* `notification` The {Notification} that was added.
#
#
Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidAddNotification
:
(
callback
)
->
@emitter
.
on
'
did-add-notification
'
, callback
###
Section: Adding Notifications
###
#
Public: Add a success notification.
#
#
* `message` A {String} message
#
* `options` (optional) An options {Object} with the following keys:
#
* `detail` (optional) A {String} with additional details about the
#
notification.
#
* `dismissable` (optional) A {Boolean} indicating whether this
#
notification can be dismissed by the user. Defaults to `false`.
#
* `icon` (optional) A {String} name of an icon from Octicons to display
#
in the notification header. Defaults to `'check'`.
addSuccess
:
(
message
,
options
)
->
@
addNotification
(
new
Notification
(
'
success
'
, message, options))
#
Public: Add an informational notification.
#
#
* `message` A {String} message
#
* `options` (optional) An options {Object} with the following keys:
#
* `detail` (optional) A {String} with additional details about the
#
notification.
#
* `dismissable` (optional) A {Boolean} indicating whether this
#
notification can be dismissed by the user. Defaults to `false`.
#
* `icon` (optional) A {String} name of an icon from Octicons to display
#
in the notification header. Defaults to `'info'`.
addInfo
:
(
message
,
options
)
->
@
addNotification
(
new
Notification
(
'
info
'
, message, options))
#
Public: Add a warning notification.
#
#
* `message` A {String} message
#
* `options` (optional) An options {Object} with the following keys:
#
* `detail` (optional) A {String} with additional details about the
#
notification.
#
* `dismissable` (optional) A {Boolean} indicating whether this
#
notification can be dismissed by the user. Defaults to `false`.
#
* `icon` (optional) A {String} name of an icon from Octicons to display
#
in the notification header. Defaults to `'alert'`.
addWarning
:
(
message
,
options
)
->
@
addNotification
(
new
Notification
(
'
warning
'
, message, options))
#
Public: Add an error notification.
#
#
* `message` A {String} message
#
* `options` (optional) An options {Object} with the following keys:
#
* `detail` (optional) A {String} with additional details about the
#
notification.
#
* `dismissable` (optional) A {Boolean} indicating whether this
#
notification can be dismissed by the user. Defaults to `false`.
#
* `icon` (optional) A {String} name of an icon from Octicons to display
#
in the notification header. Defaults to `'flame'`.
addError
:
(
message
,
options
)
->
@
addNotification
(
new
Notification
(
'
error
'
, message, options))
#
Public: Add a fatal error notification.
#
#
* `message` A {String} message
#
* `options` (optional) An options {Object} with the following keys:
#
* `detail` (optional) A {String} with additional details about the
#
notification.
#
* `dismissable` (optional) A {Boolean} indicating whether this
#
notification can be dismissed by the user. Defaults to `false`.
#
* `icon` (optional) A {String} name of an icon from Octicons to display
#
in the notification header. Defaults to `'bug'`.
addFatalError
:
(
message
,
options
)
->
@
addNotification
(
new
Notification
(
'
fatal
'
, message, options))
add
:
(
type
,
message
,
options
)
->
@
addNotification
(
new
Notification
(type, message, options))
addNotification
:
(
notification
)
->
@notifications
.
push
(notification)
@emitter
.
emit
(
'
did-add-notification
'
, notification)
notification
###
Section: Getting Notifications
###
#
Public: Get all the notifications.
#
#
Returns an {Array} of {Notification}s.
getNotifications
:
->
@notifications
.
slice
()
###
Section: Managing Notifications
###
clear
:
->
@notifications
=
[]
Back
|
FazBrowse Home
|
New Git URL