Skip to content

Commit 4a09fa0

Browse files
committed
Sync with Kendo UI Professional
1 parent 049d2f3 commit 4a09fa0

File tree

3 files changed

+365
-32
lines changed

3 files changed

+365
-32
lines changed

docs/controls/drawer/hierarchy.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,48 @@ The Kendo UI Drawer provides the built-in functionality to create a hierarchical
1414

1515
To utilize the hierarchy functionality of the Kendo UI Drawer:
1616

17-
1. Add list elements with data-role attribute `drawer-item` and class `hidden` to the drawer [`template`](/api/javascript/ui/drawer/configuration/template).
17+
1. Add list elements with data-role attribute `drawer-item` and class `hidden` to the drawer [`template`](/api/javascript/ui/drawer/configuration/template). Use the `data-level` attribute to specify the hierarchy level of each item.
1818

1919
```javascript
2020
$("#drawer").kendoDrawer({
21-
template: "<ul> \
22-
<li data-role='drawer-item' class='k-selected'><span class='k-icon k-i-information'></span><span class='k-item-text' data-id='GettingStarted'>Getting Started</span><span class='k-spacer'></span><span class='k-icon k-i-arrow-chevron-right'></span></li> \
23-
<li data-role='drawer-separator'></li> \
24-
<li data-role='drawer-item' class='hidden'><span class='k-icon k-i-none'></span><span class='k-icon k-i-question'></span><span class='k-item-text' data-id='Kendo'>About Kendo UI</span></li> \
25-
<li data-role='drawer-item' class='hidden'><span class='k-icon k-i-none'></span><span class='k-icon k-i-palette'></span><span class='k-item-text' data-id='ThemeSupport'>Supported Themes</span></li> \
26-
<li data-role='drawer-separator'></li> \
27-
<li data-role='drawer-item'><span class='k-icon k-i-zoom'></span><span class='k-item-text' data-id='Overview'>Overview</span><span class='k-spacer'></span><span class='k-icon k-i-arrow-chevron-right'></li> \
28-
<li data-role='drawer-item' class='hidden'><span class='k-icon k-i-none'></span><span class='k-icon k-i-js'></span><span class='k-item-text' data-id='About'>About Kendo</span></li> \
29-
<li data-role='drawer-item' class='hidden'><span class='k-icon k-i-none'></span><span class='k-icon k-i-style-builder'></span><span class='k-item-text' data-id='All'>All Kendo Components</span></li> \
30-
<li data-role='drawer-separator'></li> \
31-
<li data-role='drawer-item'><span class='k-icon k-i-star'></span><span class='k-item-text' data-id='Popular'>Most popular components</span></li> \
32-
</ul>"
21+
template: `<ul>
22+
<li data-role='drawer-item' data-level='0'>${kendo.ui.icon("info-circle")}<span class='k-item-text' data-id='GettingStarted'>Getting Started</span><span class='k-spacer'></span><span class='k-drawer-toggle'>${kendo.ui.icon("chevron-right")}</span></li>
23+
<li data-role='drawer-separator'></li>
24+
<li data-role='drawer-item' data-level='1' class='k-hidden'>${kendo.ui.icon("question-circle")}<span class='k-item-text' data-id='Kendo'>About Kendo UI</span></li>
25+
<li data-role='drawer-item' data-level='1' class='k-hidden'>${kendo.ui.icon("palette")}<span class='k-item-text' data-id='ThemeSupport'>Supported Themes</span></li>
26+
<li data-role='drawer-separator'></li>
27+
<li data-role='drawer-item' data-level='0' class='k-selected'>${kendo.ui.icon("search")}<span class='k-item-text' data-id='Overview'>Overview</span><span class='k-spacer'></span><span class='k-drawer-toggle'>${kendo.ui.icon("chevron-down")}</span></li>
28+
<li data-role='drawer-item' data-level='1'>${kendo.ui.icon("js")}<span class='k-item-text' data-id='About'>About Kendo</span></li>
29+
<li data-role='drawer-item' data-level='1'>${kendo.ui.icon("building-blocks")}</span><span class='k-item-text' data-id='All'>All Kendo Components</span></li>
30+
<li data-role='drawer-separator'></li>
31+
<li data-role='drawer-item' data-level='0'>${kendo.ui.icon("star")}<span class='k-item-text' data-id='Popular'>Most popular components</span></li>
32+
</ul>`,
3333
});
3434
```
3535

36+
The hierarchy levels are determined by the Kendo themes and currently support levels from `0` to `5`. If no `data-level` attribute is specified, the Drawer will automatically set it to `0`. Setting `data-level='6'` or higher will have no visual effect as only levels 0-5 are styled by the themes.
37+
3638
1. In the [`itemClick`](/api/javascript/ui/drawer/events/itemclick) event of the drawer handle the expansion and collapse of the hierarchical items.
3739

3840
```javascript
3941
$("#drawer").kendoDrawer({
40-
itemClick: function (e) {
42+
itemClick: (e) => {
4143
if (!e.item.hasClass("k-drawer-separator")) {
4244
var drawerContainer = e.sender.drawerContainer;
43-
var expandIcon = e.item.find("span.k-i-arrow-chevron-right");
44-
var collapseIcon = e.item.find("span.k-i-arrow-chevron-down");
45-
drawerContainer.find("#drawer-content > div").addClass("hidden");
46-
drawerContainer.find("#drawer-content").find("#" + e.item.find(".k-item-text").attr("data-id")).removeClass("hidden");
45+
var expandIcon = e.item.find("span.k-svg-i-chevron-right");
46+
var collapseIcon = e.item.find("span.k-svg-i-chevron-down");
47+
drawerContainer.find("#drawer-content > div").addClass("k-hidden");
48+
drawerContainer.find("#drawer-content").find("#" + e.item.find(".k-item-text").attr("data-id")).removeClass("k-hidden");
4749
48-
/* If the expandIcon is visible, the sub-items are hidden. Clicking on the icon should remove the hidden class and reveal the items.*/
4950
if (expandIcon.length) {
50-
e.item.nextAll(".k-drawer-item:not(.k-drawer-separator):lt(2)").removeClass("hidden");
51-
expandIcon.removeClass("k-i-arrow-chevron-right").addClass("k-i-arrow-chevron-down");
51+
e.item.nextAll(".k-drawer-item:not(.k-drawer-separator):lt(2)").removeClass("k-hidden");
52+
expandIcon.replaceWith(kendo.ui.icon("chevron-down"));
5253
}
5354
5455
/* If the collapseIcon is visible, the sub-items are visible. Clicking on the icon should add the hidden class and hide the items. */
5556
if (collapseIcon.length) {
56-
e.item.nextAll(".k-drawer-item:not(.k-drawer-separator):lt(2)").addClass("hidden");
57-
collapseIcon.addClass("k-i-arrow-chevron-right").removeClass("k-i-arrow-chevron-down");
57+
e.item.nextAll(".k-drawer-item:not(.k-drawer-separator):lt(2)").addClass("k-hidden");
58+
collapseIcon.replaceWith(kendo.ui.icon("chevron-right"));
5859
}
5960
}
6061
}

0 commit comments

Comments
 (0)