Wiki source code of The XWiki Notification Widget

Version 2.2 by Silvia Macovei on 2010/05/10

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

Get Connected