Skip to content

Commit 5915ca2

Browse files
author
Dimo Dimov
committed
Improve Notification docs and new stacking how-to
1 parent 6174f56 commit 5915ca2

File tree

2 files changed

+86
-2
lines changed

2 files changed

+86
-2
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
title: Stack static notifications to the left or right
3+
page_title: Stack static notifications to the left or right
4+
description: Stack static notifications to the left or right
5+
---
6+
7+
# Stack static notifications to the left or right
8+
9+
The following demo shows how to stack static notifications to the left or to the right
10+
11+
#### Example
12+
13+
```html
14+
<style>
15+
16+
.notification-container
17+
{
18+
min-height: 2.6em;
19+
padding: .3em .6em;
20+
overflow: auto;
21+
}
22+
23+
#ntfLeft
24+
{
25+
text-align: right;
26+
}
27+
28+
.notification-container .k-notification
29+
{
30+
padding: .3em .6em;
31+
}
32+
33+
</style>
34+
35+
<script id="my-template" type="text/x-kendo-template">
36+
<div class="my-container">
37+
#= message #
38+
</div>
39+
</script>
40+
41+
<p><button id="buttonRight" class="k-button">Stack to the right</button></p>
42+
<div id="ntfRight" class="k-block notification-container"></div>
43+
44+
<p><button id="buttonLeft" class="k-button">Stack to the left</button></p>
45+
<div id="ntfLeft" class="k-block notification-container"></div>
46+
47+
<script>
48+
49+
$(function() {
50+
var options = {
51+
stacking: "down",
52+
autoHideAfter: 0,
53+
templates: [{
54+
type: "my-type",
55+
template: $("#my-template").html()
56+
}],
57+
show: function(e) {
58+
e.element.css("display", "inline-block");
59+
}
60+
};
61+
var ntfRight = $("#ntfRight").kendoNotification($.extend(options, {stacking: "down", appendTo: "#ntfRight"})).data("kendoNotification");
62+
var ntfLeft = $("#ntfLeft").kendoNotification($.extend(options, {stacking: "up", appendTo: "#ntfLeft"})).data("kendoNotification");
63+
64+
$(".k-button").click(function (e) {
65+
var notificationWidget = $(e.target).is("#buttonLeft") ? ntfLeft : ntfRight;
66+
var d = new Date();
67+
notificationWidget.show({
68+
message: kendo.toString(d, 'HH:MM:ss.') + kendo.toString(d.getMilliseconds(), "000")
69+
}, "my-type");
70+
71+
var container = $(notificationWidget.options.appendTo);
72+
container.scrollTop(container[0].scrollHeight);
73+
});
74+
75+
76+
});
77+
78+
</script>
79+
```

web/notification/overview.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ By default, postponing is disabled.
103103

104104
## Positioning and stacking
105105

106+
### Popup messages
107+
106108
By default, the **Notification** widget creates popups, which overlay the other page content. If no position settings are defined,
107109
the first popup will be displayed near the bottom-right corner of the browser viewport and subsequent popups will stack upwards.
108110
Positioning and stacking can be controlled independently. If no stacking setting is defined, the popups will stack upwards or downwards, depending on the positioning settings
@@ -146,9 +148,12 @@ In this way every **Notification** instance can recognize and manage its own cur
146148

147149
> Using several **Notification** widget instances, which display notifications at the same place on the page is not recommended, because the notifications from the multiple instances will overlap.
148150
151+
### Static messages
152+
149153
The **Notification** widget can also display "static" notifications, which do not overlay other elements, but instead take part in the so-called *normal flow* of the page content.
150-
In this case positioning settings do not make sense and are ignored. Stacking can be downwards (by default) or upwards.
151-
Static notifications are displayed, if a target container is specified. One widget instance can display either popup or static notifications, not both at the same time.
154+
In this case positioning settings do not make sense and are ignored. When static notifications are used, the stacking direction can only be set to `down` (default) or `up`,
155+
depending on whether new messages should appear after or before existing ones. Static notifications are displayed, if a target container is specified.
156+
One widget instance can display either popup or static notifications, not both at the same time.
152157

153158
### Example - enable static notifications
154159

0 commit comments

Comments
 (0)