-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathkendo.html.chiplist.js
65 lines (55 loc) · 2 KB
/
kendo.html.chiplist.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import "./kendo.html.base.js";
export const __meta__ = {
id: "html.chiplist",
name: "Html.ChipList",
category: "web",
description: "HTML rendering utility for Kendo UI for jQuery.",
depends: ["html.base"],
features: []
};
(function($, undefined) {
var kendo = window.kendo,
HTMLBase = kendo.html.HTMLBase;
var renderChipList = function(element, options) {
if (arguments[0] === undefined || $.isPlainObject(arguments[0])) {
options = element;
element = $("<div></div>");
}
return (new HTMLChipList(element, options)).html();
};
var HTMLChipList = HTMLBase.extend({
init: function(element, options) {
var that = this;
HTMLBase.fn.init.call(that, element, options);
that.wrapper = that.element.addClass("k-chip-list");
that._applyAriaAttributes(options);
that._addClasses();
},
options: {
name: "HTMLChipList",
size: "medium",
stylingOptions: ["size"]
},
_applyAriaAttributes: function(options) {
var that = this;
options = $.extend({ selectable: "none" }, options);
var ariaLabelOption = (options.attributes || {})["aria-label"];
if (options.selectable !== "none") {
that.element.attr({
"aria-multiselectable": options.selectable === "multiple",
role: "listbox",
"aria-label": ariaLabelOption || that.element.attr("id") + " listbox",
"aria-orientation": "horizontal"
});
} else {
that.element.removeAttr("role aria-label aria-multiselectable aria-orientation");
}
}
});
$.extend(kendo.html, {
renderChipList: renderChipList,
HTMLChipList: HTMLChipList
});
kendo.cssProperties.registerPrefix("HTMLChipList", "k-chip-list-");
})(window.kendo.jQuery);
export default kendo;