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