Skip to content

Commit 8c6997a

Browse files
committed
Sync with Kendo UI Professional
1 parent 1cf287c commit 8c6997a

File tree

8 files changed

+221
-128
lines changed

8 files changed

+221
-128
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: Focused Time
3+
page_title: Focused Time
4+
description: "Get started with the {{ site.product }} TimePicker and learn how to set the focused time when the user opens the pop-up."
5+
slug: htmlhelpers_timepicker_aspnetcore_focusedtime
6+
position: 4
7+
---
8+
9+
# Focused Time
10+
11+
The TimePicker allows you to define focused time when the time chooser pop-up is opened. This will provide a convenient way for the user to easily select a highlighted time slot. Also, the pop-up container list is automatically scrolled according to this time item.
12+
13+
The following example demonstrates how apply the FocusedTime setting. By default, the TimePicker focuses the default time of 12:00 AM. However, a common requirement is to have the focused time to be 8:00 AM.
14+
15+
```HtmlHelper
16+
@(Html.Kendo().TimePicker()
17+
.Name("timepicker")
18+
.DateInput()
19+
.FocusTime(new DateTime(2023, 5, 5, 8, 0, 0))
20+
)
21+
```
22+
{% if site.core %}
23+
```TagHelper
24+
<kendo-timepicker name="timepicker"
25+
date-input="true" focus-time="new DateTime(2023, 5, 5, 8, 0, 0)">
26+
</kendo-timepicker>
27+
```
28+
{% endif %}
29+
30+
## See Also
31+
32+
* [Server-Side API](/api/timepicker)

docs-aspnet/html-helpers/editors/timepicker/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ The TimePicker TagHelper configuration options are passed as attributes.
6262
## Functionality and Features
6363

6464
* [Selected time]({% slug htmlhelpers_timepicker_aspnetcore_selectedtimes %})—The TimePicker allows you to render a pre-selected time and also define the minimum and maximum time it displays.
65+
* [Focused time]({% slug htmlhelpers_timepicker_aspnetcore_focusedtime %})—The TimePicker allows you to define focused time when the pop-up is opened.
6566
* [Formats]({% slug formats_timepicker_aspnetcore %})—The TimePicker allows you to define its time formatting.
6667
* [Validation]({% slug htmlhelpers_timepicker_aspnetcore_validation %})—The TimePicker is designed to keep its input value unchanged even when the typed time is invalid.
6768
* [Globalization]({% slug globalization_timepicker_aspnetcore %})—The globalization process combines the translation of component messages (localization) with adapting them to specific cultures.

docs-aspnet/html-helpers/navigation/drawer/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ The following example demonstrates how to define the Drawer.
7171
* [Templates]({% slug templates_drawer_aspnetcore %})&mdash;With the built-in item templates, you control how the Drawer items are rendered.
7272
* [Hierarchy]({% slug hierarchy_drawer_aspnetcore %})&mdash;The Drawer allows you to display hierarchically organized items.
7373
* [Events]({% slug events_drawer %})&mdash;The Drawer allows you to handle its events and implement custom functionality.
74+
* **Expanded**&mdash;The Drawer can be expanded by default using this setting.
7475

7576
## Next Steps
7677

docs/_tools/check-redirects.sh

Lines changed: 0 additions & 117 deletions
This file was deleted.

docs/api/javascript/ui/tabstrip.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,34 @@ Sets the scroll amount (in pixels) applied when the user clicks on a scroll butt
491491
});
492492
</script>
493493

494+
### sortable `Boolean` *(default: false)*
495+
496+
If enabled, users will be able to sort the tabs by dragging them to the desired position.
497+
498+
#### Example
499+
500+
<div id="tabstrip">
501+
<ul>
502+
<li>Tab Header Number 1</li>
503+
<li>Tab Header Number 2</li>
504+
<li>Tab Header Number 3</li>
505+
<li>Tab Header Number 4</li>
506+
<li>Tab Header Number 5</li>
507+
<li>Tab Header Number 6</li>
508+
</ul>
509+
<div>Content 1</div>
510+
<div>Content 2</div>
511+
<div>Content 3</div>
512+
<div>Content 4</div>
513+
<div>Content 5</div>
514+
<div>Content 6</div>
515+
</div>
516+
<script>
517+
$("#tabstrip").kendoTabStrip({
518+
sortable: true
519+
});
520+
</script>
521+
494522
### tabPosition `String`*(default: "top")*
495523

496524
Specifies the position of the widget tabs. Valid values are `"top"` (default), `"left"`, `"right"` and `"bottom"`.

src/kendo.tabstrip.js

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import "./kendo.data.js";
22
import "./kendo.icons.js";
3+
import "./kendo.sortable.js";
34

45
var __meta__ = {
56
id: "tabstrip",
67
name: "TabStrip",
78
category: "web",
89
description: "The TabStrip widget displays a collection of tabs with associated tab content.",
9-
depends: [ "data", "icons" ],
10+
depends: [ "data", "icons", "sortable" ],
1011
features: [ {
1112
id: "tabstrip-fx",
1213
name: "Animation",
@@ -68,13 +69,14 @@ var __meta__ = {
6869
templates = {
6970
content: (data) =>
7071
`<div class='k-tabstrip-content k-content' ${data.contentAttributes(data)} tabindex='0'>${data.content(data.item)}</div>`,
71-
itemWrapper: ({ tag, item , contentUrl, textAttributes, image, sprite, text }) =>
72+
textWrapper: ({ tag, item , contentUrl, textAttributes, image, sprite, text }) =>
7273
`<${tag(item)} class='k-link' ${contentUrl(item)} ${textAttributes(item)}>` +
7374
`${image(item)}${sprite(item)}${text(item)}` +
7475
`</${tag(item)}>`,
75-
item: (data) =>
76+
item: (data) =>templates.itemWrapper(data,`${data.textWrapper(data)}`),
77+
itemWrapper: (data, item) =>
7678
`<li class='${data.wrapperCssClass(data.group, data.item)}' role='tab' ${data.item.active ? "aria-selected='true'" : ''}>` +
77-
`${data.itemWrapper(data)}` +
79+
item +
7880
"</li>",
7981
image: ({ imageUrl }) => `<img class='k-image' alt='' src='${imageUrl}' />`,
8082
sprite: ({ spriteCssClass }) => `<span class='k-sprite ${spriteCssClass}'></span>`,
@@ -199,6 +201,7 @@ var __meta__ = {
199201

200202
that._tabPosition();
201203
that._scrollable();
204+
that._sortable();
202205
that._processContentUrls();
203206
that._attachEvents();
204207

@@ -236,6 +239,7 @@ var __meta__ = {
236239
dataSpriteCssClass: "",
237240
dataContentUrlField: "",
238241
tabPosition: "top",
242+
tabTemplate: null,
239243
animation: {
240244
open: {
241245
effects: "expand:vertical fadeIn",
@@ -251,7 +255,8 @@ var __meta__ = {
251255
applyMinHeight: true,
252256
scrollable: {
253257
distance: DEFAULTDISTANCE
254-
}
258+
},
259+
sortable: false
255260
},
256261

257262
setDataSource: function(dataSource) {
@@ -779,6 +784,11 @@ var __meta__ = {
779784
text: text(view[idx])
780785
};
781786

787+
if (options.tabTemplate) {
788+
tab.model = view[idx];
789+
tab.template = options.tabTemplate;
790+
}
791+
782792
if (options.dataEncodedField) {
783793
tab.encoded = encoded(view[idx]);
784794
}
@@ -1383,6 +1393,44 @@ var __meta__ = {
13831393
});
13841394
},
13851395

1396+
_sortable: function() {
1397+
var that = this,
1398+
options = that.options,
1399+
position = options.tabPosition,
1400+
axis = position === 'left' || position === 'right' ? 'y' : 'x';
1401+
1402+
if (!that.options.sortable) {
1403+
return;
1404+
}
1405+
1406+
that.sortable = new kendo.ui.Sortable(that.tabGroup, {
1407+
filter: "li.k-tabstrip-item",
1408+
axis,
1409+
container: that.tabWrapper,
1410+
hint: el => `<div id='hint' class='k-tabstrip k-tabstrip-${position}'>
1411+
<div class= 'k-tabstrip-items-wrapper k-hstack'>
1412+
<ul class='k-tabstrip-items k-reset'>
1413+
<li class='k-item k-tabstrip-item k-first k-active k-tab-on-${position}'>${el.html()}</li>
1414+
</ul>
1415+
</div>
1416+
</div>`,
1417+
change: that._sortChange.bind(that),
1418+
start: e => that.activateTab(e.item)
1419+
});
1420+
1421+
},
1422+
1423+
_sortChange: function(e) {
1424+
var that = this,
1425+
reference = that.tabGroup.children().eq(e.newIndex);
1426+
1427+
if (e.oldIndex < e.newIndex) {
1428+
that.insertAfter(e.item, reference);
1429+
} else {
1430+
that.insertBefore(e.item, reference);
1431+
}
1432+
},
1433+
13861434
_tabPosition: function() {
13871435
var that = this,
13881436
tabPosition = that.options.tabPosition;
@@ -1565,13 +1613,18 @@ var __meta__ = {
15651613
options = extend({ tabStrip: {}, group: {} }, options);
15661614

15671615
var empty = templates.empty,
1568-
item = options.item;
1616+
item = options.item,
1617+
templateOptions = extend(options, {
1618+
image: item.imageUrl ? templates.image : empty,
1619+
sprite: item.spriteCssClass ? templates.sprite : empty,
1620+
textWrapper: templates.textWrapper
1621+
}, rendering);
1622+
1623+
if (item.template) {
1624+
return templates.itemWrapper(templateOptions, kendo.template(item.template)(item.model));
1625+
}
15691626

1570-
return templates.item(extend(options, {
1571-
image: item.imageUrl ? templates.image : empty,
1572-
sprite: item.spriteCssClass ? templates.sprite : empty,
1573-
itemWrapper: templates.itemWrapper
1574-
}, rendering));
1627+
return templates.item(templateOptions);
15751628
},
15761629

15771630
renderContent: function(options) {

tests/tabstrip/initialization.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,16 @@
108108
assert.equal(tabstrip.wrapper.find("div[tabindex=0]").length, 2);
109109
});
110110

111+
it("function tab template is applied correctly", function() {
112+
tabstrip = new kendo.ui.TabStrip(dom, {
113+
dataContentField: "content",
114+
tabTemplate: data => `<span class='customClass'>${data.text}</span>`,
115+
dataSource: [{
116+
text: "one", content: "Content one"
117+
}]
118+
});
119+
120+
assert.equal(tabstrip.wrapper.find("span.customClass").text(), "one");
121+
});
111122
});
112123
}());

0 commit comments

Comments
 (0)