Wiki source code of The XWiki Notification Widget

Version 3.1 by Guillaume Delhumeau on 2011/12/22

Hide last authors
Guillaume Delhumeau 3.1 1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
Oana Florea 1.1 4
5 {{warning}}
6 This tutorial is a work in progress.
7 {{/warning}}
8
9 {{info}}
10 This is a Javascript widget bundled by default with the XWiki platform.
11 {{/info}}
12
13 = Usage =
14
15 The XWiki notification widget is a general purpose notification JavaScript class, displaying a simple message for the user, at the bottom of the screen.
16 Features:
17
18 * Several default aspects: ##plain##, ##info##, ##warning##, ##error##, ##inprogress##, ##done##.
19 * Stacking of multiple notifications on the screen.
20 * Possibility to replace a notification with another one, preserving the position.
21 * Automatic hide after a configurable period of time.
22 * Configurable icon, background and text color.
23
24 To display a notification, it suffices to create a new ##XWiki.widgets.Notification## object. Constructor parameters:
25
26 |=Parameter|=Description|=Optional
27 |##text##|The notification text|no
28 |##type##|The notification type, one of ##plain##, ##info##, ##warning##, ##error##, ##inprogress##, ##done##. If an unknown or no type is passed, ##plain## is used by default.|yes
29 |##options##|Additional configuration; supported options:(((
30 * ##timeout##: number of seconds to keep the notification on the screen. Use 0 or false to keep it until manually removed.
31 * ##inactive##: don't show the notification when the object is created, manually call ##show## later</li>
32 * ##icon##: a custom image to use
33 * ##color##: a custom color for the text
34 * ##backgroundColor##: a custom color for the background
35 )))|yes
36
37 Default parameters for the predefined notification types:
38
39 |=Notification Type|=Parameter Values
40 |##plain##|(((
41 * ##timeout##: 5
42 * ##icon##: none
43 * ##color##: black
44 * ##background##: #EEE
45 )))
46 |##info##|(((
47 * ##timeout##: 5
48 * ##icon##: (i)
49 * ##color##: #28C
50 * ##background##: #DDF
51 )))
52 |##warning##|(((
53 * ##timeout##: 5
54 * ##icon##: /!\
55 * ##color##: 000
56 * ##background##: #FFD
57 )))
58 |##error##|(((
59 * ##timeout##: 10
60 * ##icon##: (!)
61 * ##color##: #900
62 * ##background##: #EDD
63 )))
64 |##inprogress##|(((
65 * ##timeout##: false
66 * ##icon##: spinning
67 * ##color##: #268
68 * ##background##: #EEE
69 )))
70 |##done##|(((
71 * ##timeout##: 2
72 * ##icon##: (v)
73 * ##color##: #090
74 * ##background##: #EFD
75 )))
76
77 = Example =
78
79 [[image:notification.png||style="vertical-align: middle;"]]
80
81 {{html}}
82 To see the notification in action just click <a href="#Example" onclick="new XWiki.widgets.Notification('This tutorial is a work in progress.', 'warning');">here</a>.
83 {{/html}}
84
85 Here is the example code of the XWiki widget which displays the ##inprogress## notification above:
86
Guillaume Delhumeau 3.1 87 {{code langauge="html"}}
88 To see the notification in action just click <a href="#Example" onclick="new XWiki.widgets.Notification('This tutorial is a work in progress.', 'warning');">here</a>.
Oana Florea 1.1 89 {{/code}}
90
91
92 = Tips =
93
94 Check out the Javascript code:
95
96 * for your wiki instance:**{{{http://localhost:8080/xwiki/bin/skin/resources/uicomponents/widgets/notification.js}}}**
Guillaume Delhumeau 3.1 97 * from git: [[https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-web/src/main/webapp/resources/uicomponents/widgets/notification.js]].
Oana Florea 1.1 98
99 Check out the CSS code:
100
101 * for your wiki instance:**{{{http://localhost:8080/xwiki/bin/skin/resources/uicomponents/widgets/notification.css}}}**
Guillaume Delhumeau 3.1 102 * from git: [[https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-web/src/main/webapp/resources/uicomponents/widgets/notification.css]].

Get Connected