Skip to content

Commit 7139a99

Browse files
author
Kendo Bot
committed
Sync with Kendo UI Professional
1 parent ad2864e commit 7139a99

File tree

6 files changed

+118
-5
lines changed

6 files changed

+118
-5
lines changed

docs/api/javascript/ui/notification.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,20 @@ Defines a Kendo UI template to be used with the corresponding notification type.
357357

358358
See the [example above](/api/javascript/ui/notification#configuration-templates).
359359

360+
### title `String` *(default: null)*
361+
362+
Defines the title attribute value for the Notification wrapper.
363+
364+
#### Example
365+
366+
<span id="notification"></span>
367+
<script>
368+
$("#notification").kendoNotification({
369+
title: "Custom title"
370+
});
371+
$("#notification").getKendoNotification().show("Kendo Notification");
372+
</script>
373+
360374
### width `Number|String` *(default: null)*
361375

362376
Defines the notifications' width. Numbers are treated as pixels.

src/kendo.draganddrop.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,8 @@ var __meta__ = { // jshint ignore:line
921921
}
922922
});
923923

924+
clearInterval(this._scrollInterval);
925+
this._scrollInterval = null;
924926
this._cancel(this._trigger(DRAGEND, e));
925927
},
926928

src/kendo.notification.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ var __meta__ = { // jshint ignore:line
3838
RIGHT = "right",
3939
UP = "up",
4040
NS = ".kendoNotification",
41-
WRAPPER = '<div class="k-widget k-popup k-notification"></div>',
41+
WRAPPER = '<div role="alert" aria-live="polite" class="k-widget k-popup k-notification"></div>',
4242
TEMPLATE = '<div class="k-notification-wrap">' +
43-
'<span class="k-icon k-i-#=typeIcon#" title="#=typeIcon#"></span>' +
43+
'<span class="k-icon k-i-#:typeIcon#" title="#:typeIcon#"></span>' +
4444
'<div class="k-notification-content">#=content#</div>' +
45-
'<span class="#: closeButton ? "" : "k-hidden"# k-icon k-i-close" title="Hide"></span>' +
45+
'<span aria-hidden="true" class="#: closeButton ? "" : "k-hidden"# k-icon k-i-close" title="Hide"></span>' +
4646
'</div>',
4747
SAFE_TEMPLATE = TEMPLATE.replace("#=content#", "#:content#");
4848

@@ -89,6 +89,7 @@ var __meta__ = { // jshint ignore:line
8989
width: null,
9090
height: null,
9191
templates: [],
92+
title: null,
9293
animation: {
9394
open: {
9495
effects: "fade:in",
@@ -353,12 +354,15 @@ var __meta__ = { // jshint ignore:line
353354
var that = this,
354355
options = that.options,
355356
wrapper = $(WRAPPER),
357+
contentId = kendo.guid(),
356358
args, defaultArgs;
357359

358360
if (!type) {
359361
type = INFO;
360362
}
361363

364+
wrapper.attr("aria-label", type);
365+
362366
if (content !== null && content !== undefined && content !== "") {
363367

364368
if (kendo.isFunction(content)) {
@@ -377,10 +381,16 @@ var __meta__ = { // jshint ignore:line
377381
.addClass(KNOTIFICATION + "-" + type)
378382
.toggleClass(KNOTIFICATION + "-button", options.button)
379383
.toggleClass(KNOTIFICATION + "-closable", options.button)
380-
.attr("data-role", "alert")
384+
.attr({
385+
"data-role": "alert",
386+
title: options.title
387+
})
381388
.css({width: options.width, height: options.height})
382389
.append(that._getCompiled(type, safe)(args));
383390

391+
wrapper.find(".k-notification-content").attr("id", contentId);
392+
wrapper.attr("aria-describedby", contentId);
393+
384394
that.angular("compile", function(){
385395
return {
386396
elements: wrapper,

tests/notification/aria.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
(function() {
2+
describe("Notification WAI-ARIA", function() {
3+
beforeEach(function() {
4+
5+
});
6+
afterEach(function() {
7+
if (notification) {
8+
notification.destroy();
9+
}
10+
$(".k-notification").each(function(idx, element) {
11+
var popup = $(element).data("kendoPopup");
12+
if (popup) {
13+
popup.destroy();
14+
}
15+
$(element).remove();
16+
});
17+
});
18+
19+
it("Notification has appropriate role", function() {
20+
createNotification();
21+
notification.show("foo");
22+
23+
var element = $(".k-notification");
24+
25+
assert.equal(element.attr("role"), "alert");
26+
});
27+
28+
it("Notification has appropriate aria-live", function() {
29+
createNotification();
30+
notification.show("foo");
31+
32+
var element = $(".k-notification");
33+
34+
assert.equal(element.attr("aria-live"), "polite");
35+
});
36+
37+
it("Notification has appropriate aria-label", function() {
38+
createNotification();
39+
notification.show("foo", "error");
40+
41+
var element = $(".k-notification");
42+
43+
assert.equal(element.attr("aria-label"), "error");
44+
});
45+
46+
it("Notification has appropriate aria-describedby", function() {
47+
createNotification();
48+
notification.show("foo", "error");
49+
50+
var element = $(".k-notification");
51+
52+
assert.equal(element.attr("aria-describedby"), element.find(".k-notification-content").attr("id"));
53+
});
54+
55+
it("Notification close button has aria-hidden set", function() {
56+
createNotification({
57+
button: true
58+
});
59+
notification.show("foo");
60+
61+
var element = $(".k-notification .k-i-close");
62+
63+
assert.equal(element.attr("aria-hidden"), "true");
64+
});
65+
66+
it("Notification does not violate AXE", function(done) {
67+
createNotification({
68+
button: true
69+
});
70+
notification.show("foo");
71+
72+
axeRun($(".k-notification").parent(), done);
73+
});
74+
});
75+
}());

tests/notification/initialization.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107

108108
var defaultFunc = notification._getCompiled();
109109
var params = { typeIcon: "info", content: "foo", closeButton: false };
110-
var defaultOutput = '<div class="k-notification-wrap"><span class="k-icon k-i-info" title="info"></span><div class="k-notification-content">foo</div><span class="k-hidden k-icon k-i-close" title="Hide"></span></div>';
110+
var defaultOutput = '<div class="k-notification-wrap"><span class="k-icon k-i-info" title="info"></span><div class="k-notification-content">foo</div><span aria-hidden="true" class="k-hidden k-icon k-i-close" title="Hide"></span></div>';
111111

112112
assert.equal(typeof defaultFunc, "function");
113113
assert.equal(defaultFunc(params), defaultOutput);
@@ -308,6 +308,17 @@
308308
}, 400);
309309
});
310310

311+
it("title is applied to the Notification element", function() {
312+
createNotification({
313+
title: "custom title"
314+
});
315+
notification.show("foo");
316+
317+
var element = $(".k-notification");
318+
319+
assert.equal(element.attr("title"), "custom title");
320+
});
321+
311322
it("hide button is displayed if button property is set to true", function() {
312323
createNotification({
313324
button: true

typescript/kendo.all.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7173,6 +7173,7 @@ declare namespace kendo.ui {
71737173
position?: NotificationPosition;
71747174
stacking?: string;
71757175
templates?: NotificationTemplate[];
7176+
title?: string;
71767177
width?: number|string;
71777178
hide?(e: NotificationHideEvent): void;
71787179
show?(e: NotificationShowEvent): void;

0 commit comments

Comments
 (0)